Skip to content

Commit 7278f5b

Browse files
committed
Demonstrate issue uncovered by previous commit
> run -Xprint-types -Ytest-pickler -Ystop-after:pickler tests/pos/pickleinf.scala [error] (no source file, offset = 0): error: value of type <notype> does not take parameters The issue seems to be that the type of $1$.bar is incorrect: sel: Select(Ident($1$),bar) sel.tpe.widen: MethodType(List(name, dummy), List(TypeRef(TermRef(NoPrefix,$1$),Bar$$N), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala),Int)), TypeRef(TermRef(ThisType(TypeRef(NoPrefix,<root>)),scala),Int)) sel.tpe.signature: Signature(List(java.lang.Object, scala.Int),scala.Int) In the type, the first argument has type `Bar$$N`, but its type should be constrained to `Int`, the result is that in the signature the first parameter has type `Object` instead of `Int`.
1 parent 4426342 commit 7278f5b

File tree

3 files changed

+13
-0
lines changed

3 files changed

+13
-0
lines changed

src/dotty/tools/dotc/core/tasty/TreePickler.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,9 @@ class TreePickler(pickler: TastyPickler) {
311311
case tp: NamedType if tp.name.isShadowedName => tp.name
312312
case _ => name
313313
}
314+
println("sel: " + tree)
315+
println("sel.tpe.widen: " + tree.tpe.widen)
316+
println("sel.tpe.signature: " + tree.tpe.signature)
314317
val sig = tree.tpe.signature
315318
if (sig == Signature.NotAMethod) pickleName(realName)
316319
else pickleNameAndSig(realName, sig)

test/dotc/tests.scala

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ class tests extends CompilerTest {
5353
// This directory doesn't exist anymore
5454
// @Test def pickle_pickling = compileDir(coreDir, "pickling", testPickling)
5555
@Test def pickle_ast = compileDir(dotcDir, "ast", testPickling)
56+
@Test def pickle_inf = compileFile(posDir, "pickleinf", testPickling)
5657

5758
//@Test def pickle_core = compileDir(dotcDir, "core", testPickling, xerrors = 2) // two spurious comparison errors in Types and TypeOps
5859

tests/pos/pickleinf.scala

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
class Bar[N] {
2+
def bar(name: N, dummy: Int = 42): Int = 0
3+
}
4+
5+
object Test {
6+
def test(): Unit = {
7+
(new Bar).bar(10)
8+
}
9+
}

0 commit comments

Comments
 (0)