From c481e95b2f3d0a8cc98b106c971506e102702d06 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 4 Jun 2003 15:14:14 +0000 Subject: *** empty log message *** --- sources/scalac/typechecker/Analyzer.java | 9 +++++++-- test/files/neg/bounds.check | 4 ++++ test/files/neg/bounds.scala | 12 ++++++++++++ test/neg/bounds.check | 4 ++++ test/neg/bounds.scala | 12 ++++++++++++ 5 files changed, 39 insertions(+), 2 deletions(-) create mode 100644 test/files/neg/bounds.check create mode 100644 test/files/neg/bounds.scala create mode 100644 test/neg/bounds.check create mode 100644 test/neg/bounds.scala diff --git a/sources/scalac/typechecker/Analyzer.java b/sources/scalac/typechecker/Analyzer.java index eb9758b198..1e8ec9daa9 100644 --- a/sources/scalac/typechecker/Analyzer.java +++ b/sources/scalac/typechecker/Analyzer.java @@ -1644,12 +1644,15 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { if (pt != Type.ErrorType) error(tree.pos, ex.msg); return tree.setType(Type.ErrorType); } +/* if (!(tree.type instanceof Type.MethodType)) tree = make.Apply(tree.pos, tree, Tree.EMPTY_ARRAY) .setType(tree.type); +*/ } } else if (clazz.isSubClass(definitions.SEQ_CLASS)) { // set type to instantiated sequence class constructor + // todo: should we admit even supertypes of the target type? Type seqtp = pt.baseType(clazz); if (seqtp != Type.NoType) { tree.type = seqConstructorType(seqtp, pt); @@ -2031,8 +2034,10 @@ public class Analyzer extends Transformer implements Modifiers, Kinds { int i = 0; while (i < tparams.length && (context.delayArgs || - argtypes[i].isSubType( - tparams[i].info().subst(tparams, argtypes)))) + (argtypes[i].isSubType( + tparams[i].info().subst(tparams, argtypes)) && + tparams[i].loBound().subst(tparams, argtypes) + .isSubType(argtypes[i])))) i++; if (i == tparams.length) { return copy.TypeApply(tree, fn1, args1) diff --git a/test/files/neg/bounds.check b/test/files/neg/bounds.check new file mode 100644 index 0000000000..0f4693da88 --- /dev/null +++ b/test/files/neg/bounds.check @@ -0,0 +1,4 @@ +bounds.scala:11: constructor A of type [T >: I](T)A[T] cannot be applied to [T] +class B[T >: J](init: T) extends A[T](init) { + ^ +one error found diff --git a/test/files/neg/bounds.scala b/test/files/neg/bounds.scala new file mode 100644 index 0000000000..f9fbeaa674 --- /dev/null +++ b/test/files/neg/bounds.scala @@ -0,0 +1,12 @@ +class I { + def i(): Unit = {} +} +class J extends I { + def j(): Unit = {} +} +class A[T >: I](init: T) { + var y: T = new B(); + class B() extends I {} +} +class B[T >: J](init: T) extends A[T](init) { +} diff --git a/test/neg/bounds.check b/test/neg/bounds.check new file mode 100644 index 0000000000..0f4693da88 --- /dev/null +++ b/test/neg/bounds.check @@ -0,0 +1,4 @@ +bounds.scala:11: constructor A of type [T >: I](T)A[T] cannot be applied to [T] +class B[T >: J](init: T) extends A[T](init) { + ^ +one error found diff --git a/test/neg/bounds.scala b/test/neg/bounds.scala new file mode 100644 index 0000000000..f9fbeaa674 --- /dev/null +++ b/test/neg/bounds.scala @@ -0,0 +1,12 @@ +class I { + def i(): Unit = {} +} +class J extends I { + def j(): Unit = {} +} +class A[T >: I](init: T) { + var y: T = new B(); + class B() extends I {} +} +class B[T >: J](init: T) extends A[T](init) { +} -- cgit v1.2.3