Skip to content

Commit

Permalink
Add package in front of class to avoid compiler confusion
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
ioannakok and rtyley committed Aug 11, 2022
1 parent 017d2a8 commit 7b32253
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
6 changes: 3 additions & 3 deletions admin/app/dfp/DataMapper.scala
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ import dfp.ApiHelper.{isPageSkin, optJavaInt, toJodaTime, toSeq}
// These mapping functions use libraries that are only available in admin to create common DFP data models.
class DataMapper(
adUnitService: AdUnitService,
placementService: PlacementService,
customTargetingService: CustomTargetingService,
customFieldService: CustomFieldService,
placementService: dfp.PlacementService,
customTargetingService: dfp.CustomTargetingService,
customFieldService: dfp.CustomFieldService,
) {

def toGuAdUnit(dfpAdUnit: AdUnit): GuAdUnit = {
Expand Down
2 changes: 1 addition & 1 deletion applications/app/crosswords/CrosswordPage.scala
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class CrosswordPageWithContent(content: CrosswordContent) extends ContentPage {
override lazy val item = content
val crossword = content.crossword

import CrosswordSvg.{BorderSize, CellSize}
import crosswords.CrosswordSvg.{BorderSize, CellSize}

case class SvgDimensions(width: Int, height: Int) {
def styleString: String = s"width: $width; height: $height"
Expand Down
2 changes: 1 addition & 1 deletion common/app/model/content.scala
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ object Content {
val metadata = MetaData.make(fields, apiContent)
val elements = Elements.make(apiContent)
val tags = Tags.make(apiContent)
val commercial = Commercial.make(tags, apiContent)
val commercial = model.Commercial.make(tags, apiContent)
val trail = Trail.make(tags, fields, commercial, elements, metadata, apiContent)
val sharelinks = ShareLinks(tags, fields, metadata)
val atoms = Atoms.make(apiContent, sharelinks.pageShares)
Expand Down
8 changes: 4 additions & 4 deletions common/test/model/ContentTest.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ class ContentTest
elements = Some(elements),
)

val trail: ContentType = Content(content)
val trail: model.ContentType = Content(content)

trail.fields.linkText should be("Some article")
trail.metadata.url should be("/foo/2012/jan/07/bar")
Expand Down Expand Up @@ -162,7 +162,7 @@ class ContentTest

it should "returns the correct shortUrlId (gu.com)" in {

def contentWithShortUrl(shortUrl: String): ContentType =
def contentWithShortUrl(shortUrl: String): model.ContentType =
Content(article.copy(fields = Some(ContentFields(shortUrl = Some(shortUrl)))))

contentWithShortUrl("http://gu.com/p/3r1b5").fields.shortUrlId should be("/p/3r1b5")
Expand All @@ -171,7 +171,7 @@ class ContentTest

it should "returns the correct shortUrlId (www.theguardian.com)" in {

def contentWithShortUrl(shortUrl: String): ContentType =
def contentWithShortUrl(shortUrl: String): model.ContentType =
Content(article.copy(fields = Some(ContentFields(shortUrl = Some(shortUrl)))))

contentWithShortUrl("http://www.theguardian.com/p/3r1b5").fields.shortUrlId should be("/p/3r1b5")
Expand Down Expand Up @@ -282,7 +282,7 @@ class ContentTest
contentType: String,
elements: List[ApiElement],
maybeByline: Option[String] = None,
): ContentType = {
): model.ContentType = {
Content(contentApi(contentType, elements, maybeByline))
}

Expand Down
2 changes: 1 addition & 1 deletion onward/app/controllers/TaggedContentController.scala
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class TaggedContentController(

private def render(trails: Seq[ContentType])(implicit request: RequestHeader): Result =
Cached(300) {
JsonComponent(
common.JsonComponent(
"trails" -> JsArray(trails.map { trail =>
Json.obj(
("webTitle", trail.metadata.webTitle),
Expand Down

0 comments on commit 7b32253

Please sign in to comment.