From d668ebcb7af2855611e38978adf3c1161d872936 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 24 Nov 2018 21:08:33 +0100 Subject: [PATCH 1/3] Add position to synthetic lazy implicit symbols --- compiler/src/dotty/tools/dotc/core/Symbols.scala | 4 ++-- compiler/src/dotty/tools/dotc/typer/Implicits.scala | 2 +- compiler/test/dotc/pos-test-pickling.blacklist | 2 -- 3 files changed, 3 insertions(+), 5 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/core/Symbols.scala b/compiler/src/dotty/tools/dotc/core/Symbols.scala index d6b6ed1efd1c..588d2abe1743 100644 --- a/compiler/src/dotty/tools/dotc/core/Symbols.scala +++ b/compiler/src/dotty/tools/dotc/core/Symbols.scala @@ -265,8 +265,8 @@ trait Symbols { this: Context => newConstructor(cls, EmptyFlags, Nil, Nil) /** Create a synthetic lazy implicit value */ - def newLazyImplicit(info: Type): TermSymbol = - newSymbol(owner, LazyImplicitName.fresh(), Lazy, info) + def newLazyImplicit(info: Type, coord: Coord): TermSymbol = + newSymbol(owner, LazyImplicitName.fresh(), Lazy, info, coord = coord) /** Create a symbol representing a selftype declaration for class `cls`. */ def newSelfSym(cls: ClassSymbol, name: TermName = nme.WILDCARD, selfInfo: Type = NoType): TermSymbol = diff --git a/compiler/src/dotty/tools/dotc/typer/Implicits.scala b/compiler/src/dotty/tools/dotc/typer/Implicits.scala index c5fd94db5330..ee31378b971d 100644 --- a/compiler/src/dotty/tools/dotc/typer/Implicits.scala +++ b/compiler/src/dotty/tools/dotc/typer/Implicits.scala @@ -671,7 +671,7 @@ trait Implicits { self: Typer => */ val (formalValue, lazyImplicit, argCtx) = formal match { case ExprType(fv) => - val lazyImplicit = ctx.newLazyImplicit(fv) + val lazyImplicit = ctx.newLazyImplicit(fv, pos) (fv, lazyImplicit, lazyImplicitCtx(lazyImplicit)) case _ => (formal, NoSymbol, ctx) } diff --git a/compiler/test/dotc/pos-test-pickling.blacklist b/compiler/test/dotc/pos-test-pickling.blacklist index 22a41321bf77..56c5fd00e292 100644 --- a/compiler/test/dotc/pos-test-pickling.blacklist +++ b/compiler/test/dotc/pos-test-pickling.blacklist @@ -4,8 +4,6 @@ i1812.scala i1867.scala i3067.scala i3149.scala -i3542-1.scala -i3585.scala i3692.scala i3976.scala i4125.scala From 8ac046d647e2a453a4ca94e0aee68d729ba08aae Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 24 Nov 2018 21:24:43 +0100 Subject: [PATCH 2/3] Fix Tasty printing for ENUM --- compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala index c337db42b9f9..8db9e0a4d277 100644 --- a/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala +++ b/compiler/src/dotty/tools/dotc/core/tasty/TastyFormat.scala @@ -526,6 +526,7 @@ object TastyFormat { case STATIC => "STATIC" case OBJECT => "OBJECT" case TRAIT => "TRAIT" + case ENUM => "ENUM" case LOCAL => "LOCAL" case SYNTHETIC => "SYNTHETIC" case ARTIFACT => "ARTIFACT" From 334dffd0df331c6258746a43295fc15f0c452677 Mon Sep 17 00:00:00 2001 From: Guillaume Martres Date: Sat, 24 Nov 2018 22:51:10 +0100 Subject: [PATCH 3/3] Properly type bounds of wildcards in hk positions Typing a TypeBoundsTree(Empty, Empty) leads to a TypeBoundsTree(Nothing, Any), if this tree appears in a higher-kinded position, we manually set its type, but we don't change the upper bound which is still "Any" and ends up being pickled. To avoid this issue this commit simply replaces the TypeBoundsTree with a synthetic TypeTree with the proper type and position, which is all that we need. --- compiler/src/dotty/tools/dotc/typer/Typer.scala | 5 ++--- compiler/test/dotc/pos-test-pickling.blacklist | 1 - 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/typer/Typer.scala b/compiler/src/dotty/tools/dotc/typer/Typer.scala index dca8c7137111..1b36eb4a4eac 100644 --- a/compiler/src/dotty/tools/dotc/typer/Typer.scala +++ b/compiler/src/dotty/tools/dotc/typer/Typer.scala @@ -1290,7 +1290,6 @@ class Typer extends Namer case _ => } if (desugaredArg.isType) { - var res = typed(desugaredArg, argPt) arg match { case TypeBoundsTree(EmptyTree, EmptyTree) if tparam.paramInfo.isLambdaSub && @@ -1302,10 +1301,10 @@ class Typer extends Namer // type parameter in `C`. // The transform does not apply for patterns, where empty bounds translate to // wildcard identifiers `_` instead. - res = res.withType(tparamBounds) + TypeTree(tparamBounds).withPos(arg.pos) case _ => + typed(desugaredArg, argPt) } - res } else desugaredArg.withType(UnspecifiedErrorType) } diff --git a/compiler/test/dotc/pos-test-pickling.blacklist b/compiler/test/dotc/pos-test-pickling.blacklist index 56c5fd00e292..6398ace56bb3 100644 --- a/compiler/test/dotc/pos-test-pickling.blacklist +++ b/compiler/test/dotc/pos-test-pickling.blacklist @@ -5,7 +5,6 @@ i1867.scala i3067.scala i3149.scala i3692.scala -i3976.scala i4125.scala implicit-dep.scala inline-access-levels