summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/compiler/scala/tools/nsc/typechecker/Infer.scala2
-rw-r--r--test/files/neg/bug4302.check4
-rw-r--r--test/files/neg/bug4302.flags1
-rw-r--r--test/files/neg/bug4302.scala3
4 files changed, 9 insertions, 1 deletions
diff --git a/src/compiler/scala/tools/nsc/typechecker/Infer.scala b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
index e15c8fae66..296e555559 100644
--- a/src/compiler/scala/tools/nsc/typechecker/Infer.scala
+++ b/src/compiler/scala/tools/nsc/typechecker/Infer.scala
@@ -1312,7 +1312,7 @@ trait Infer {
((bound contains sym) ||
sym.name == tpnme.WILDCARD || {
val e = context.scope.lookupEntry(sym.name)
- (e ne null) && e.sym == sym && e.owner == context.scope
+ (e ne null) && e.sym == sym && !e.sym.isTypeParameterOrSkolem && e.owner == context.scope
})
tp match {
case SingleType(pre, _) =>
diff --git a/test/files/neg/bug4302.check b/test/files/neg/bug4302.check
new file mode 100644
index 0000000000..ca33748cfd
--- /dev/null
+++ b/test/files/neg/bug4302.check
@@ -0,0 +1,4 @@
+bug4302.scala:2: error: abstract type T in type T is unchecked since it is eliminated by erasure
+ def hasMatch[T](x: AnyRef) = x.isInstanceOf[T]
+ ^
+one error found
diff --git a/test/files/neg/bug4302.flags b/test/files/neg/bug4302.flags
new file mode 100644
index 0000000000..779916d58f
--- /dev/null
+++ b/test/files/neg/bug4302.flags
@@ -0,0 +1 @@
+-unchecked -Xfatal-warnings \ No newline at end of file
diff --git a/test/files/neg/bug4302.scala b/test/files/neg/bug4302.scala
new file mode 100644
index 0000000000..53565f05c2
--- /dev/null
+++ b/test/files/neg/bug4302.scala
@@ -0,0 +1,3 @@
+object Test {
+ def hasMatch[T](x: AnyRef) = x.isInstanceOf[T]
+}