From 83e4ef1bb6be65c6a367671be728aac089c1a156 Mon Sep 17 00:00:00 2001 From: Georgi Krastev Date: Wed, 4 Dec 2019 03:39:41 +0100 Subject: [PATCH] Add missing pattern match case in varianceInType --- .../scala/reflect/internal/Variances.scala | 1 + test/files/neg/t9911.check | 4 +++ test/files/neg/t9911.scala | 28 +++++++++++++++++++ 3 files changed, 33 insertions(+) create mode 100644 test/files/neg/t9911.check create mode 100644 test/files/neg/t9911.scala diff --git a/src/reflect/scala/reflect/internal/Variances.scala b/src/reflect/scala/reflect/internal/Variances.scala index c472272bb955..6a4b0e3b2f53 100644 --- a/src/reflect/scala/reflect/internal/Variances.scala +++ b/src/reflect/scala/reflect/internal/Variances.scala @@ -292,6 +292,7 @@ trait Variances { case PolyType(tparams, restpe) => inSyms(tparams).flip & inType(restpe) case ExistentialType(tparams, restpe) => inSyms(tparams) & inType(restpe) case AnnotatedType(annots, tp) => inAnnots(annots) & inType(tp) + case SuperType(thistpe, supertpe) => inType(thistpe) & inType(supertpe) } def apply(tp: Type, tparam: Symbol): Variance = { diff --git a/test/files/neg/t9911.check b/test/files/neg/t9911.check new file mode 100644 index 000000000000..3d83b7415739 --- /dev/null +++ b/test/files/neg/t9911.check @@ -0,0 +1,4 @@ +t9911.scala:23: error: super may not be used on value source + super.source.getSomething + ^ +one error found diff --git a/test/files/neg/t9911.scala b/test/files/neg/t9911.scala new file mode 100644 index 000000000000..1da80358f4cf --- /dev/null +++ b/test/files/neg/t9911.scala @@ -0,0 +1,28 @@ +// This should say: +// Error: super may not be used on value source +class ScalacBug { + + class SomeClass { + + type U + + // Changing T or U stops the problem + def getSomething[T]: U = ??? + } + + trait Base { + + // Changing this to a def like it should be stops the problem + val source: SomeClass = ??? + } + + class Bug extends Base { + + override val source = { + // Not calling the function stops the problem + super.source.getSomething + ??? + } + } + +}