Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add package in import when Scala 2.13 compiler gets confused #25368

Merged
merged 1 commit into from
Aug 11, 2022

Conversation

ioannakok
Copy link
Contributor

@ioannakok ioannakok commented Aug 10, 2022

Scala 2.13 hets confused when deciding which class to import so in some cases we have to also specify the package.

For example, in the following case the compiler thinks we are trying to use com.google.api.ads.admanager.axis.v202108.CustomTargetingService.

[error] /Users/ioanna_kokkini/Projects/frontend/admin/app/dfp/DataMapper.scala:47:36: value targetingKey is not a member of com.google.api.ads.admanager.axis.v202108.CustomTargetingService
[error]             customTargetingService.targetingKey(session)(criterion.getKeyId),
[error]

So we have to explicitly add the package in front of the class we are trying to use. Instead of:

class DataMapper(
    adUnitService: AdUnitService,
    placementService: PlacementService,
    customTargetingService: CustomTargetingService,
    customFieldService: CustomFieldService,
)

we do:

class DataMapper(
    adUnitService: AdUnitService,
    placementService: dfp.PlacementService,
    customTargetingService: dfp.CustomTargetingService,
    customFieldService: dfp.CustomFieldService,
)

Co-authored-by: Roberto Tyley roberto.tyley@guardian.co.uk

Pulled from the mega-PR: #25190

@ioannakok ioannakok force-pushed the scala-2.13/add-package-to-import branch from ff0a2c4 to dddef6f Compare August 11, 2022 11:43
Copy link
Member

@rtyley rtyley left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me - thanks again for the great description that makes clear the error that's being fixed! 👍

@ioannakok ioannakok marked this pull request as ready for review August 11, 2022 11:55
@ioannakok ioannakok requested a review from a team as a code owner August 11, 2022 11:55
@ioannakok ioannakok changed the title Add package in import Add package in import when Scala 2.13 compiler gets confused Aug 11, 2022
@ioannakok ioannakok mentioned this pull request Aug 11, 2022
2 tasks
@ioannakok ioannakok force-pushed the scala-2.13/add-package-to-import branch from dddef6f to 7b32253 Compare August 11, 2022 13:58
Scala 2.13 hets confused when deciding which class to import so in some cases we have to also specify the package.

For example, in the following case the compiler thinks we are trying to use `com.google.api.ads.admanager.axis.v202108.CustomTargetingService`.

```
[error] /Users/ioanna_kokkini/Projects/frontend/admin/app/dfp/DataMapper.scala:47:36: value targetingKey is not a member of com.google.api.ads.admanager.axis.v202108.CustomTargetingService
[error]             customTargetingService.targetingKey(session)(criterion.getKeyId),
[error]
```

So we have to explicitly add the package in front of the class we are trying to use. Instead of:

```
class DataMapper(
    adUnitService: AdUnitService,
    placementService: PlacementService,
    customTargetingService: CustomTargetingService,
    customFieldService: CustomFieldService,
)
```

we do:

```
class DataMapper(
    adUnitService: AdUnitService,
    placementService: dfp.PlacementService,
    customTargetingService: dfp.CustomTargetingService,
    customFieldService: dfp.CustomFieldService,
)
```

Co-authored-by: Roberto Tyley <roberto.tyley@guardian.co.uk>
@ioannakok ioannakok force-pushed the scala-2.13/add-package-to-import branch from 7b32253 to 7ee5023 Compare August 11, 2022 14:33
@ioannakok ioannakok merged commit 811a325 into main Aug 11, 2022
@ioannakok ioannakok deleted the scala-2.13/add-package-to-import branch August 11, 2022 14:52
@prout-bot
Copy link
Collaborator

Seen on PROD (merged by @ioannakok 6 hours and 7 minutes ago)

@rtyley rtyley added the Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 label Feb 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Scala 2.13 See https://github.com/guardian/maintaining-scala-projects/issues/2 Seen-on-PROD
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants