aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorodersky <odersky@gmail.com>2014-06-20 15:15:16 +0200
committerodersky <odersky@gmail.com>2014-06-20 15:15:16 +0200
commita8cb929a368f01819c16393a97291e82bc4a2738 (patch)
tree82af4c43d1167cc0d897d31b1afa855c068f856e
parent7bc5cd18ee4f881f223e9a317e6c6a329942d5af (diff)
parentc2175ec910165308e81c48bd8ca8910c50862be4 (diff)
downloaddotty-a8cb929a368f01819c16393a97291e82bc4a2738.tar.gz
dotty-a8cb929a368f01819c16393a97291e82bc4a2738.tar.bz2
dotty-a8cb929a368f01819c16393a97291e82bc4a2738.zip
Merge pull request #136 from dotty-staging/fix/systematic-prototypes
Fix/systematic prototypes
-rw-r--r--src/dotty/tools/dotc/ast/Desugar.scala10
-rw-r--r--src/dotty/tools/dotc/core/SymDenotations.scala51
-rw-r--r--src/dotty/tools/dotc/core/TypeComparer.scala4
-rw-r--r--src/dotty/tools/dotc/core/TyperState.scala13
-rw-r--r--src/dotty/tools/dotc/parsing/Parsers.scala11
-rw-r--r--src/dotty/tools/dotc/printing/RefinedPrinter.scala11
-rw-r--r--src/dotty/tools/dotc/typer/Applications.scala15
-rw-r--r--src/dotty/tools/dotc/typer/Implicits.scala2
-rw-r--r--src/dotty/tools/dotc/typer/Namer.scala3
-rw-r--r--src/dotty/tools/dotc/typer/ProtoTypes.scala19
-rw-r--r--src/dotty/tools/dotc/typer/Typer.scala51
-rw-r--r--test/dotc/tests.scala1
-rw-r--r--tests/disabled/java-interop/pos/t2569/Child.scala (renamed from tests/untried/pos/t2569/Child.scala)0
-rw-r--r--tests/disabled/java-interop/pos/t2569/Parent.java (renamed from tests/untried/pos/t2569/Parent.java)0
-rw-r--r--tests/disabled/java-interop/pos/t2764/Ann.java (renamed from tests/untried/pos/t2764/Ann.java)0
-rw-r--r--tests/disabled/java-interop/pos/t2764/Enum.java (renamed from tests/untried/pos/t2764/Enum.java)0
-rw-r--r--tests/disabled/java-interop/pos/t2764/Use.scala (renamed from tests/untried/pos/t2764/Use.scala)0
-rw-r--r--tests/disabled/java-interop/pos/t294/Ann.java (renamed from tests/untried/pos/t294/Ann.java)0
-rw-r--r--tests/disabled/java-interop/pos/t294/Ann2.java (renamed from tests/untried/pos/t294/Ann2.java)0
-rw-r--r--tests/disabled/java-interop/pos/t294/Test_1.scala (renamed from tests/untried/pos/t294/Test_1.scala)0
-rw-r--r--tests/disabled/java-interop/pos/t294/Test_2.scala (renamed from tests/untried/pos/t294/Test_2.scala)0
-rw-r--r--tests/disabled/java-interop/pos/t2940/Cycle.java (renamed from tests/untried/pos/t2940/Cycle.java)0
-rw-r--r--tests/disabled/java-interop/pos/t2940/Error.scala (renamed from tests/untried/pos/t2940/Error.scala)0
-rw-r--r--tests/disabled/java-interop/pos/t2956/BeanDefinitionVisitor.java (renamed from tests/untried/pos/t2956/BeanDefinitionVisitor.java)0
-rwxr-xr-xtests/disabled/java-interop/pos/t2956/t2956.scala (renamed from tests/untried/pos/t2956/t2956.scala)0
-rw-r--r--tests/neg/t2994.scala (renamed from tests/untried/pos/t2994a.scala)8
-rw-r--r--tests/pending/pos/t2613.scala11
-rw-r--r--tests/pending/pos/t2693.scala6
-rw-r--r--tests/pending/pos/t2782.scala (renamed from tests/untried/pos/t2782.scala)0
-rw-r--r--tests/pending/pos/t2795-new.scala (renamed from tests/untried/pos/t2795-new.scala)0
-rw-r--r--tests/pending/pos/t2795-old.scala (renamed from tests/untried/pos/t2795-old.scala)0
-rwxr-xr-xtests/pending/pos/t2913.scala (renamed from tests/untried/pos/t2913.scala)2
-rw-r--r--tests/pending/pos/t2945.scala (renamed from tests/untried/pos/t2945.scala)4
-rw-r--r--tests/pos/implicitonSelect.scala8
-rw-r--r--tests/pos/resultGuidesInference.scala7
-rw-r--r--tests/pos/t2405.scala (renamed from tests/new/t2405.scala)0
-rw-r--r--tests/pos/t2421.scala (renamed from tests/new/t2421.scala)0
-rw-r--r--tests/pos/t2421_delitedsl.scala (renamed from tests/new/t2421_delitedsl.scala)0
-rw-r--r--tests/pos/t2421b_pos.scala (renamed from tests/new/t2421b_pos.scala)0
-rw-r--r--tests/pos/t2421c.scala (renamed from tests/new/t2421c.scala)0
-rwxr-xr-xtests/pos/t2425.scala (renamed from tests/new/t2425.scala)0
-rw-r--r--tests/pos/t2435.scala (renamed from tests/new/t2435.scala)0
-rw-r--r--tests/pos/t2441pos.scala (renamed from tests/new/t2441pos.scala)0
-rw-r--r--tests/pos/t2444.scala (renamed from tests/new/t2444.scala)0
-rw-r--r--tests/pos/t245.scala (renamed from tests/new/t245.scala)0
-rw-r--r--tests/pos/t2454.scala (renamed from tests/pending/pos/t2454.scala)0
-rw-r--r--tests/pos/t247.scala (renamed from tests/new/t247.scala)0
-rwxr-xr-xtests/pos/t2484.scala (renamed from tests/new/t2484.scala)0
-rw-r--r--tests/pos/t2486.scala (renamed from tests/new/t2486.scala)0
-rw-r--r--tests/pos/t2500.scala (renamed from tests/untried/pos/t2500.scala)0
-rwxr-xr-xtests/pos/t2504.scala (renamed from tests/untried/pos/t2504.scala)1
-rw-r--r--tests/pos/t252.scala (renamed from tests/untried/pos/t252.scala)0
-rwxr-xr-xtests/pos/t2545.scala (renamed from tests/untried/pos/t2545.scala)0
-rw-r--r--tests/pos/t2591.scala (renamed from tests/untried/pos/t2591.scala)0
-rw-r--r--tests/pos/t2610.scala17
-rw-r--r--tests/pos/t2619.scala80
-rw-r--r--tests/pos/t262.scala14
-rw-r--r--tests/pos/t2624.scala4
-rwxr-xr-xtests/pos/t2635.scala16
-rw-r--r--tests/pos/t2660.scala25
-rw-r--r--tests/pos/t2664.scala9
-rw-r--r--tests/pos/t2665.scala3
-rw-r--r--tests/pos/t2667.scala6
-rw-r--r--tests/pos/t2669.scala28
-rw-r--r--tests/pos/t267.scala55
-rwxr-xr-xtests/pos/t2683.scala7
-rw-r--r--tests/pos/t2691.scala16
-rw-r--r--tests/pos/t2698.scala14
-rw-r--r--tests/pos/t2708.scala (renamed from tests/untried/pos/t2708.scala)0
-rw-r--r--tests/pos/t2726/SQLBuilder_1.scala (renamed from tests/untried/pos/t2726/SQLBuilder_1.scala)0
-rw-r--r--tests/pos/t2726/t2726_2.scala (renamed from tests/untried/pos/t2726/t2726_2.scala)0
-rw-r--r--tests/pos/t2741/2741_1.scala (renamed from tests/untried/pos/t2741/2741_1.scala)0
-rw-r--r--tests/pos/t2741/2741_2.scala (renamed from tests/untried/pos/t2741/2741_2.scala)0
-rw-r--r--tests/pos/t2794.scala (renamed from tests/untried/pos/t2794.scala)0
-rw-r--r--tests/pos/t2797.scala (renamed from tests/untried/pos/t2797.scala)0
-rw-r--r--tests/pos/t2799.flags (renamed from tests/untried/pos/t2799.flags)0
-rw-r--r--tests/pos/t2799.scala (renamed from tests/untried/pos/t2799.scala)0
-rw-r--r--tests/pos/t2809.scala (renamed from tests/untried/pos/t2809.scala)0
-rw-r--r--tests/pos/t2810.scala (renamed from tests/untried/pos/t2810.scala)0
-rw-r--r--tests/pos/t284-pos.scala (renamed from tests/untried/pos/t284-pos.scala)0
-rw-r--r--tests/pos/t287.scala (renamed from tests/untried/pos/t287.scala)0
-rw-r--r--tests/pos/t289.scala (renamed from tests/untried/pos/t289.scala)0
-rw-r--r--tests/pos/t2910.scala (renamed from tests/untried/pos/t2910.scala)0
-rw-r--r--tests/pos/t2939.scala (renamed from tests/untried/pos/t2939.scala)0
-rw-r--r--tests/pos/t295.scala (renamed from tests/untried/pos/t295.scala)0
-rw-r--r--tests/pos/t296.scala (renamed from tests/untried/pos/t296.scala)0
-rw-r--r--tests/pos/t2973.scala (renamed from tests/untried/pos/t2973.scala)0
-rw-r--r--tests/pos/test.scala6
-rw-r--r--tests/pos/tuplePatDef.scala4
-rw-r--r--tests/pos/tycons.scala22
-rw-r--r--tests/untried/pos/t2994b.scala7
91 files changed, 502 insertions, 69 deletions
diff --git a/src/dotty/tools/dotc/ast/Desugar.scala b/src/dotty/tools/dotc/ast/Desugar.scala
index 513dee2ff..ba2b62faa 100644
--- a/src/dotty/tools/dotc/ast/Desugar.scala
+++ b/src/dotty/tools/dotc/ast/Desugar.scala
@@ -241,6 +241,14 @@ object desugar {
val constr = cpy.DefDef(constr1,
constr1.mods, constr1.name, constrTparams, constrVparamss, constr1.tpt, constr1.rhs)
+ // Add constructor type parameters to auxiliary constructors
+ val normalizedBody = body map {
+ case ddef: DefDef if ddef.name.isConstructorName =>
+ cpy.DefDef(ddef, ddef.mods, ddef.name, constrTparams, ddef.vparamss, ddef.tpt, ddef.rhs)
+ case stat =>
+ stat
+ }
+
val derivedTparams = constrTparams map derivedTypeParam
val derivedVparamss = constrVparamss nestedMap derivedTermParam
val arity = constrVparamss.head.length
@@ -376,7 +384,7 @@ object desugar {
}
cpy.TypeDef(cdef, mods, name,
cpy.Template(impl, constr, parents1, self1,
- tparamAccessors ::: vparamAccessors ::: body ::: caseClassMeths))
+ tparamAccessors ::: vparamAccessors ::: normalizedBody ::: caseClassMeths))
}
// install the watch on classTycon
diff --git a/src/dotty/tools/dotc/core/SymDenotations.scala b/src/dotty/tools/dotc/core/SymDenotations.scala
index 498f912f9..606966be9 100644
--- a/src/dotty/tools/dotc/core/SymDenotations.scala
+++ b/src/dotty/tools/dotc/core/SymDenotations.scala
@@ -321,6 +321,9 @@ object SymDenotations {
final def isAnonymousClass(implicit ctx: Context): Boolean =
initial.asSymDenotation.name startsWith tpnme.ANON_CLASS
+ final def isRefinementClass(implicit ctx: Context): Boolean =
+ name.decode == tpnme.REFINE_CLASS
+
/** Is this symbol a package object or its module class? */
def isPackageObject(implicit ctx: Context): Boolean = {
val poName = if (isType) nme.PACKAGE_CLS else nme.PACKAGE
@@ -701,6 +704,54 @@ object SymDenotations {
else
Iterator.empty
+ /** The symbol overriding this symbol in given subclass `ofclazz`.
+ *
+ * @param ofclazz is a subclass of this symbol's owner
+ */
+ final def overridingSymbol(inClass: ClassSymbol)(implicit ctx: Context): Symbol =
+ if (canMatchInheritedSymbols) matchingSymbol(inClass, inClass.thisType)
+ else NoSymbol
+
+ /** If false, this symbol cannot possibly participate in an override,
+ * either as overrider or overridee. For internal use; you should consult
+ * with isOverridingSymbol. This is used by isOverridingSymbol to escape
+ * the recursive knot.
+ */
+ private def canMatchInheritedSymbols = (
+ owner.isClass
+ && !this.isClass
+ && !this.isConstructor
+ )
+
+ /** The symbol accessed by a super in the definition of this symbol when
+ * seen from class `base`. This symbol is always concrete.
+ * pre: `this.owner` is in the base class sequence of `base`.
+ */
+ final def superSymbolIn(base: Symbol)(implicit ctx: Context): Symbol = {
+ def loop(bcs: List[ClassSymbol]): Symbol = bcs match {
+ case bc :: bcs1 =>
+ val sym = matchingSymbol(bcs.head, base.thisType)
+ .suchThat(alt => !(alt is Deferred)).symbol
+ if (sym.exists) sym else loop(bcs.tail)
+ case _ =>
+ NoSymbol
+ }
+ loop(base.info.baseClasses.dropWhile(owner != _).tail)
+ }
+
+
+ /** A a member of class `base` is incomplete if
+ * (1) it is declared deferred or
+ * (2) it is abstract override and its super symbol in `base` is
+ * nonexistent or incomplete.
+ */
+ final def isIncompleteIn(base: Symbol)(implicit ctx: Context): Boolean =
+ (this is Deferred) ||
+ (this is AbsOverride) && {
+ val supersym = superSymbolIn(base)
+ supersym == NoSymbol || supersym.isIncompleteIn(base)
+ }
+
/** The class or term symbol up to which this symbol is accessible,
* or RootClass if it is public. As java protected statics are
* otherwise completely inaccessible in scala, they are treated
diff --git a/src/dotty/tools/dotc/core/TypeComparer.scala b/src/dotty/tools/dotc/core/TypeComparer.scala
index 6174f0915..415385719 100644
--- a/src/dotty/tools/dotc/core/TypeComparer.scala
+++ b/src/dotty/tools/dotc/core/TypeComparer.scala
@@ -860,7 +860,7 @@ class TypeComparer(initctx: Context) extends DotClass {
}
/** The greatest lower bound of two types */
- def glb(tp1: Type, tp2: Type): Type = /*>|>*/ ctx.traceIndented(s"glb(${tp1.show}, ${tp2.show})", typr, show = true) /*<|<*/ {
+ def glb(tp1: Type, tp2: Type): Type = /*>|>*/ ctx.traceIndented(s"glb(${tp1.show}, ${tp2.show})", subtyping, show = true) /*<|<*/ {
if (tp1 eq tp2) tp1
else if (!tp1.exists) tp2
else if (!tp2.exists) tp1
@@ -892,7 +892,7 @@ class TypeComparer(initctx: Context) extends DotClass {
/** The least upper bound of two types
* @note We do not admit singleton types in or-types as lubs.
*/
- def lub(tp1: Type, tp2: Type): Type = /*>|>*/ ctx.traceIndented(s"lub(${tp1.show}, ${tp2.show})", typr, show = true) /*<|<*/ {
+ def lub(tp1: Type, tp2: Type): Type = /*>|>*/ ctx.traceIndented(s"lub(${tp1.show}, ${tp2.show})", subtyping, show = true) /*<|<*/ {
if (tp1 eq tp2) tp1
else if (!tp1.exists) tp1
else if (!tp2.exists) tp2
diff --git a/src/dotty/tools/dotc/core/TyperState.scala b/src/dotty/tools/dotc/core/TyperState.scala
index 6a3ac4467..8c742edab 100644
--- a/src/dotty/tools/dotc/core/TyperState.scala
+++ b/src/dotty/tools/dotc/core/TyperState.scala
@@ -152,12 +152,13 @@ extends TyperState(r) {
val savedConstraint = myConstraint
myReporter = new StoreReporter
val result = op
- if (!reporter.hasErrors) result
- else {
- myReporter = savedReporter
- myConstraint = savedConstraint
- fallback
- }
+ try
+ if (!reporter.hasErrors) result
+ else {
+ myConstraint = savedConstraint
+ fallback
+ }
+ finally myReporter = savedReporter
}
override def toText(printer: Printer): Text = constraint.toText(printer)
diff --git a/src/dotty/tools/dotc/parsing/Parsers.scala b/src/dotty/tools/dotc/parsing/Parsers.scala
index 7bc7d5516..0ad33a96c 100644
--- a/src/dotty/tools/dotc/parsing/Parsers.scala
+++ b/src/dotty/tools/dotc/parsing/Parsers.scala
@@ -447,10 +447,6 @@ object Parsers {
if (tok == BACKQUOTED_IDENT) BackquotedIdent(name)
else Ident(name)
- /** IdentOrWildcard ::= id | `_' */
- def identOrWildcard(): Name =
- if (in.token == USCORE) { in.nextToken(); nme.WILDCARD } else ident()
-
def wildcardIdent(): Ident =
atPos(accept(USCORE)) { Ident(nme.WILDCARD) }
@@ -1478,7 +1474,12 @@ object Parsers {
if (mods is VarianceFlags) in.nextToken()
}
atPos(tokenRange) {
- val name = (if (isConcreteOwner) ident() else identOrWildcard()).toTypeName
+ val name =
+ if (isConcreteOwner || in.token != USCORE) ident().toTypeName
+ else {
+ in.nextToken()
+ ctx.freshName(nme.USCORE_PARAM_PREFIX).toTypeName
+ }
val hkparams =
if (ownerKind == ParamOwner.TypeParam) Nil
else typeParamClauseOpt(ParamOwner.TypeParam)
diff --git a/src/dotty/tools/dotc/printing/RefinedPrinter.scala b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
index d0a681f90..eb6b151b4 100644
--- a/src/dotty/tools/dotc/printing/RefinedPrinter.scala
+++ b/src/dotty/tools/dotc/printing/RefinedPrinter.scala
@@ -3,11 +3,11 @@ package printing
import core._
import Texts._, Types._, Flags._, Names._, Symbols._, NameOps._, Constants._
-import Contexts.Context, Scopes.Scope, Denotations._, Annotations.Annotation
+import Contexts.Context, Scopes.Scope, Denotations._, SymDenotations._, Annotations.Annotation
import StdNames.nme
import ast.{Trees, untpd}
import typer.Namer
-import typer.ProtoTypes.{SelectionProto, ViewProto, FunProto, IgnoredProto}
+import typer.ProtoTypes.{SelectionProto, ViewProto, FunProto, IgnoredProto, dummyTreeOfType}
import Trees._
import scala.annotation.switch
@@ -126,7 +126,11 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
case tp: ViewProto =>
return toText(tp.argType) ~ " ?=>? " ~ toText(tp.resultType)
case FunProto(args, resultType, _) =>
- return "funproto(" ~ toTextGlobal(args, ", ") ~ "):" ~ toText(resultType)
+ val argsText = args match {
+ case dummyTreeOfType(tp) :: Nil if !(tp isRef defn.NullClass) => "null: " ~ toText(tp)
+ case _ => toTextGlobal(args, ", ")
+ }
+ return "FunProto(" ~ argsText ~ "):" ~ toText(resultType)
case tp: IgnoredProto =>
return "?"
case _ =>
@@ -477,6 +481,7 @@ class RefinedPrinter(_ctx: Context) extends PlainPrinter(_ctx) {
override def toText(denot: Denotation): Text = denot match {
case denot: MultiDenotation => denot.toString
+ case NoDenotation => "NoDenotation"
case _ =>
if (denot.symbol.exists) toText(denot.symbol)
else "some " ~ toText(denot.info)
diff --git a/src/dotty/tools/dotc/typer/Applications.scala b/src/dotty/tools/dotc/typer/Applications.scala
index a4c26080d..aaceac0e0 100644
--- a/src/dotty/tools/dotc/typer/Applications.scala
+++ b/src/dotty/tools/dotc/typer/Applications.scala
@@ -125,9 +125,16 @@ trait Applications extends Compatibility { self: Typer =>
protected def init() = methType match {
case methType: MethodType =>
// apply the result type constraint, unless method type is dependent
- if (!methType.isDependent)
+ if (!methType.isDependent) {
+ val savedConstraint = ctx.typerState.constraint
if (!constrainResult(methType.resultType, resultType))
- fail(err.typeMismatchStr(methType.resultType, resultType))
+ if (ctx.typerState.isCommittable)
+ // defer the problem until after the application;
+ // it might be healed by an implicit conversion
+ assert(ctx.typerState.constraint eq savedConstraint)
+ else
+ fail(err.typeMismatchStr(methType.resultType, resultType))
+ }
// match all arguments with corresponding formal parameters
matchArgs(orderedArgs, methType.paramTypes, 0)
case _ =>
@@ -434,7 +441,7 @@ trait Applications extends Compatibility { self: Typer =>
def typedApply(tree: untpd.Apply, pt: Type)(implicit ctx: Context): Tree = {
def realApply(implicit ctx: Context): Tree = track("realApply") {
- var proto = new FunProto(tree.args, ignoreIfProto(pt), this)
+ var proto = new FunProto(tree.args, IgnoredProto(pt), this)
val fun1 = typedExpr(tree.fun, proto)
// Warning: The following line is dirty and fragile. We record that auto-tupling was demanded as
@@ -454,7 +461,7 @@ trait Applications extends Compatibility { self: Typer =>
val result = app.result
ConstFold(result)
} { (failedVal, failedState) =>
- val fun2 = tryInsertImplicit(fun1, proto)
+ val fun2 = tryInsertImplicitOnQualifier(fun1, proto)
if (fun1 eq fun2) {
failedState.commit()
failedVal
diff --git a/src/dotty/tools/dotc/typer/Implicits.scala b/src/dotty/tools/dotc/typer/Implicits.scala
index d2a94e287..86d513fff 100644
--- a/src/dotty/tools/dotc/typer/Implicits.scala
+++ b/src/dotty/tools/dotc/typer/Implicits.scala
@@ -441,7 +441,7 @@ trait Implicits { self: Typer =>
lazy val funProto = fullProto match {
case proto: ViewProto =>
- FunProto(dummyTreeOfType(proto.argType) :: Nil, proto.resultType, self)
+ FunProto(untpd.TypedSplice(dummyTreeOfType(proto.argType)) :: Nil, proto.resultType, self)
case proto => proto
}
diff --git a/src/dotty/tools/dotc/typer/Namer.scala b/src/dotty/tools/dotc/typer/Namer.scala
index e9195a072..681523bd2 100644
--- a/src/dotty/tools/dotc/typer/Namer.scala
+++ b/src/dotty/tools/dotc/typer/Namer.scala
@@ -459,7 +459,8 @@ class Namer { typer: Typer =>
def checkedParentType(parent: untpd.Tree): Type = {
val ptype = parentType(parent)(ctx.fresh addMode Mode.InSuperCall)
- checkClassTypeWithStablePrefix(ptype, parent.pos, traitReq = parent ne parents.head)
+ if (cls.isRefinementClass) ptype
+ else checkClassTypeWithStablePrefix(ptype, parent.pos, traitReq = parent ne parents.head)
}
val selfInfo =
diff --git a/src/dotty/tools/dotc/typer/ProtoTypes.scala b/src/dotty/tools/dotc/typer/ProtoTypes.scala
index a72e98418..19d8d6895 100644
--- a/src/dotty/tools/dotc/typer/ProtoTypes.scala
+++ b/src/dotty/tools/dotc/typer/ProtoTypes.scala
@@ -79,13 +79,8 @@ object ProtoTypes {
}
/** A class marking ignored prototypes that can be reviealed by `deepenProto` */
- case class IgnoredProto(proto: ProtoType) extends UncachedGroundType with MatchAlways {
- override def deepenProto(implicit ctx: Context): Type = proto
- }
-
- def ignoreIfProto(tp: Type): Type = tp match {
- case proto: ProtoType => IgnoredProto(proto)
- case _ => tp
+ case class IgnoredProto(ignored: Type) extends UncachedGroundType with MatchAlways {
+ override def deepenProto(implicit ctx: Context): Type = ignored
}
/** A prototype for expressions [] that are part of a selection operation:
@@ -145,7 +140,7 @@ object ProtoTypes {
if (name.isConstructorName) WildcardType
else tp match {
case tp: UnapplyFunProto => new UnapplySelectionProto(name)
- case tp => SelectionProto(name, ignoreIfProto(tp), typer)
+ case tp => SelectionProto(name, IgnoredProto(tp), typer)
}
/** A prototype for expressions [] that are in some unspecified selection operation
@@ -413,5 +408,11 @@ object ProtoTypes {
private lazy val dummyTree = untpd.Literal(Constant(null))
/** Dummy tree to be used as an argument of a FunProto or ViewProto type */
- def dummyTreeOfType(tp: Type): Tree = dummyTree withTypeUnchecked tp
+ object dummyTreeOfType {
+ def apply(tp: Type): Tree = dummyTree withTypeUnchecked tp
+ def unapply(tree: Tree): Option[Type] = tree match {
+ case Literal(Constant(null)) => Some(tree.typeOpt)
+ case _ => None
+ }
+ }
} \ No newline at end of file
diff --git a/src/dotty/tools/dotc/typer/Typer.scala b/src/dotty/tools/dotc/typer/Typer.scala
index 050fcbc76..d6b724270 100644
--- a/src/dotty/tools/dotc/typer/Typer.scala
+++ b/src/dotty/tools/dotc/typer/Typer.scala
@@ -46,6 +46,11 @@ object Typer {
val nothingBound = 0
def isImportPrec(prec: Int) = prec == namedImport || prec == wildImport
}
+
+ /** Assert tree has a position, unless it is empty or a typed splice */
+ def assertPositioned(tree: untpd.Tree)(implicit ctx: Context) =
+ if (!tree.isEmpty && !tree.isInstanceOf[untpd.TypedSplice] && ctx.typerState.isGlobalCommittable)
+ assert(tree.pos.exists, s"position not set for $tree # ${tree.uniqueId}")
}
class Typer extends Namer with TypeAssigner with Applications with Implicits with Inferencing with Checking {
@@ -323,7 +328,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
val tpt1 = typedType(tree.tpt)
val expr1 =
if (isWildcard) tree.expr withType tpt1.tpe
- else typedExpr(tree.expr, tpt1.tpe)
+ else typed(tree.expr, tpt1.tpe)
assignType(cpy.Typed(tree, expr1, tpt1), tpt1)
}
tree.expr match {
@@ -953,7 +958,7 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
def typed(tree: untpd.Tree, pt: Type = WildcardType)(implicit ctx: Context): Tree = /*>|>*/ ctx.traceIndented (i"typing $tree", typr, show = true) /*<|<*/ {
- if (!tree.isEmpty && ctx.typerState.isGlobalCommittable) assert(tree.pos.exists, i"position not set for $tree")
+ assertPositioned(tree)
try adapt(typedUnadapted(tree, pt), pt, tree)
catch {
case ex: CyclicReference => errorTree(tree, cyclicErrorMsg(ex))
@@ -1009,17 +1014,21 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
}
}
- /** Try to insert `.apply` so that the result conforms to prototype `pt`.
- * If that fails try to insert an implicit conversion around the qualifier
- * part of `tree`. If either result conforms to `pt`, adapt it, else
- * continue with `fallBack`.
+ /** Add apply node or implicit conversions. Two strategies are tried, and the first
+ * that is succesful is picked. If neither of the strategies are succesful, continues with
+ * `fallBack`.
+ *
+ * 1st strategy: Try to insert `.apply` so that the result conforms to prototype `pt`.
+ * 2nd stratgey: If tree is a select `qual.name`, try to insert an implicit conversion
+ * around the qualifier part `qual` so that the result conforms to the expected type
+ * with wildcard result type.
*/
def tryInsertApplyOrImplicit(tree: Tree, pt: ProtoType)(fallBack: (Tree, TyperState) => Tree)(implicit ctx: Context): Tree =
tryEither { implicit ctx =>
val sel = typedSelect(untpd.Select(untpd.TypedSplice(tree), nme.apply), pt)
if (sel.tpe.isError) sel else adapt(sel, pt)
} { (failedTree, failedState) =>
- val tree1 = tryInsertImplicit(tree, pt)
+ val tree1 = tryInsertImplicitOnQualifier(tree, pt)
if (tree1 eq tree) fallBack(failedTree, failedState)
else adapt(tree1, pt)
}
@@ -1028,21 +1037,19 @@ class Typer extends Namer with TypeAssigner with Applications with Implicits wit
* `c` around `qual` so that `c(qual).name` conforms to `pt`. If that fails
* return `tree` itself.
*/
- def tryInsertImplicit(tree: Tree, pt: ProtoType)(implicit ctx: Context): Tree = ctx.traceIndented(i"try ins impl $tree $pt") { tree match {
- case Select(qual, name) =>
- val normalizedProto = pt match {
- case pt: FunProto => pt.derivedFunProto(pt.args, WildcardType, pt.typer) // drop result type, because views are disabled
- case _ => pt
- }
- val qualProto = SelectionProto(name, normalizedProto, NoViewsAllowed)
- tryEither { implicit ctx =>
- val qual1 = adaptInterpolated(qual, qualProto, EmptyTree)
- if ((qual eq qual1) || ctx.reporter.hasErrors) tree
- else typedSelect(cpy.Select(tree, untpd.TypedSplice(qual1), name), pt)
- } { (_, _) => tree
- }
- case _ => tree
- }}
+ def tryInsertImplicitOnQualifier(tree: Tree, pt: Type)(implicit ctx: Context): Tree = ctx.traceIndented(i"try insert impl on qualifier $tree $pt") {
+ tree match {
+ case Select(qual, name) =>
+ val qualProto = SelectionProto(name, pt, NoViewsAllowed)
+ tryEither { implicit ctx =>
+ val qual1 = adaptInterpolated(qual, qualProto, EmptyTree)
+ if ((qual eq qual1) || ctx.reporter.hasErrors) tree
+ else typedSelect(cpy.Select(tree, untpd.TypedSplice(qual1), name), pt)
+ } { (_, _) => tree
+ }
+ case _ => tree
+ }
+ }
def adapt(tree: Tree, pt: Type, original: untpd.Tree = untpd.EmptyTree)(implicit ctx: Context) = /*>|>*/ track("adapt") /*<|<*/ {
/*>|>*/ ctx.traceIndented(i"adapting $tree of type ${tree.tpe} to $pt", typr, show = true) /*<|<*/ {
diff --git a/test/dotc/tests.scala b/test/dotc/tests.scala
index b102c5e80..c7b0dc044 100644
--- a/test/dotc/tests.scala
+++ b/test/dotc/tests.scala
@@ -84,6 +84,7 @@ class tests extends CompilerTest {
@Test def neg_tailcall2 = compileFile(negDir, "tailcall/tailrec-2", xerrors = 2)
@Test def neg_tailcall3 = compileFile(negDir, "tailcall/tailrec-3", xerrors = 2)
@Test def neg_t1843 = compileFile(negDir, "t1843", xerrors = 1)
+ @Test def neg_t2994 = compileFile(negDir, "t2994", xerrors = 13)
@Test def dotc = compileDir(dotcDir + "tools/dotc", twice)
@Test def dotc_ast = compileDir(dotcDir + "tools/dotc/ast", twice)
diff --git a/tests/untried/pos/t2569/Child.scala b/tests/disabled/java-interop/pos/t2569/Child.scala
index 64f4dc172..64f4dc172 100644
--- a/tests/untried/pos/t2569/Child.scala
+++ b/tests/disabled/java-interop/pos/t2569/Child.scala
diff --git a/tests/untried/pos/t2569/Parent.java b/tests/disabled/java-interop/pos/t2569/Parent.java
index 89421becb..89421becb 100644
--- a/tests/untried/pos/t2569/Parent.java
+++ b/tests/disabled/java-interop/pos/t2569/Parent.java
diff --git a/tests/untried/pos/t2764/Ann.java b/tests/disabled/java-interop/pos/t2764/Ann.java
index 184fc6e86..184fc6e86 100644
--- a/tests/untried/pos/t2764/Ann.java
+++ b/tests/disabled/java-interop/pos/t2764/Ann.java
diff --git a/tests/untried/pos/t2764/Enum.java b/tests/disabled/java-interop/pos/t2764/Enum.java
index fe0755953..fe0755953 100644
--- a/tests/untried/pos/t2764/Enum.java
+++ b/tests/disabled/java-interop/pos/t2764/Enum.java
diff --git a/tests/untried/pos/t2764/Use.scala b/tests/disabled/java-interop/pos/t2764/Use.scala
index b0c108907..b0c108907 100644
--- a/tests/untried/pos/t2764/Use.scala
+++ b/tests/disabled/java-interop/pos/t2764/Use.scala
diff --git a/tests/untried/pos/t294/Ann.java b/tests/disabled/java-interop/pos/t294/Ann.java
index 934ca4629..934ca4629 100644
--- a/tests/untried/pos/t294/Ann.java
+++ b/tests/disabled/java-interop/pos/t294/Ann.java
diff --git a/tests/untried/pos/t294/Ann2.java b/tests/disabled/java-interop/pos/t294/Ann2.java
index 025b79e79..025b79e79 100644
--- a/tests/untried/pos/t294/Ann2.java
+++ b/tests/disabled/java-interop/pos/t294/Ann2.java
diff --git a/tests/untried/pos/t294/Test_1.scala b/tests/disabled/java-interop/pos/t294/Test_1.scala
index ff1f34b10..ff1f34b10 100644
--- a/tests/untried/pos/t294/Test_1.scala
+++ b/tests/disabled/java-interop/pos/t294/Test_1.scala
diff --git a/tests/untried/pos/t294/Test_2.scala b/tests/disabled/java-interop/pos/t294/Test_2.scala
index 9fb1c6e17..9fb1c6e17 100644
--- a/tests/untried/pos/t294/Test_2.scala
+++ b/tests/disabled/java-interop/pos/t294/Test_2.scala
diff --git a/tests/untried/pos/t2940/Cycle.java b/tests/disabled/java-interop/pos/t2940/Cycle.java
index eef6c23b5..eef6c23b5 100644
--- a/tests/untried/pos/t2940/Cycle.java
+++ b/tests/disabled/java-interop/pos/t2940/Cycle.java
diff --git a/tests/untried/pos/t2940/Error.scala b/tests/disabled/java-interop/pos/t2940/Error.scala
index 92f08f580..92f08f580 100644
--- a/tests/untried/pos/t2940/Error.scala
+++ b/tests/disabled/java-interop/pos/t2940/Error.scala
diff --git a/tests/untried/pos/t2956/BeanDefinitionVisitor.java b/tests/disabled/java-interop/pos/t2956/BeanDefinitionVisitor.java
index 2ff5daa25..2ff5daa25 100644
--- a/tests/untried/pos/t2956/BeanDefinitionVisitor.java
+++ b/tests/disabled/java-interop/pos/t2956/BeanDefinitionVisitor.java
diff --git a/tests/untried/pos/t2956/t2956.scala b/tests/disabled/java-interop/pos/t2956/t2956.scala
index 33803874b..33803874b 100755
--- a/tests/untried/pos/t2956/t2956.scala
+++ b/tests/disabled/java-interop/pos/t2956/t2956.scala
diff --git a/tests/untried/pos/t2994a.scala b/tests/neg/t2994.scala
index f1a4a4a12..f3009b12f 100644
--- a/tests/untried/pos/t2994a.scala
+++ b/tests/neg/t2994.scala
@@ -25,3 +25,11 @@ object Naturals {
}
}
+
+object Test {
+ trait Bar[X[_]]
+ trait Baz[S[_] <: Bar[S]] {
+ type Apply[T]
+ }
+ trait Foo[V[_] <: Bar[V]] extends Bar[Baz[V]#Apply]
+}
diff --git a/tests/pending/pos/t2613.scala b/tests/pending/pos/t2613.scala
new file mode 100644
index 000000000..c234d4c0d
--- /dev/null
+++ b/tests/pending/pos/t2613.scala
@@ -0,0 +1,11 @@
+import language.existentials
+
+object Test {
+ class Row
+
+ abstract class MyRelation [R <: Row, +Relation <: MyRelation[R, Relation]]
+
+ type M = MyRelation[_ <: Row, _ <: MyRelation]
+
+ val (x,y): (String, M) = null
+}
diff --git a/tests/pending/pos/t2693.scala b/tests/pending/pos/t2693.scala
new file mode 100644
index 000000000..5d4d0380c
--- /dev/null
+++ b/tests/pending/pos/t2693.scala
@@ -0,0 +1,6 @@
+class A {
+ trait T[A]
+ def usetHk[T[_], A](ta: T[A]) = 0
+ usetHk(new T[Int]{}: T[Int])
+ usetHk(new T[Int]{}) // fails with: found: java.lang.Object with T[Int], required: ?T[ ?A ]
+}
diff --git a/tests/untried/pos/t2782.scala b/tests/pending/pos/t2782.scala
index 3b387af80..3b387af80 100644
--- a/tests/untried/pos/t2782.scala
+++ b/tests/pending/pos/t2782.scala
diff --git a/tests/untried/pos/t2795-new.scala b/tests/pending/pos/t2795-new.scala
index e307133e0..e307133e0 100644
--- a/tests/untried/pos/t2795-new.scala
+++ b/tests/pending/pos/t2795-new.scala
diff --git a/tests/untried/pos/t2795-old.scala b/tests/pending/pos/t2795-old.scala
index 935cb1f44..935cb1f44 100644
--- a/tests/untried/pos/t2795-old.scala
+++ b/tests/pending/pos/t2795-old.scala
diff --git a/tests/untried/pos/t2913.scala b/tests/pending/pos/t2913.scala
index 55b72bed4..21700e71a 100755
--- a/tests/untried/pos/t2913.scala
+++ b/tests/pending/pos/t2913.scala
@@ -1,3 +1,5 @@
+import language.noAutoTupling // try with on and off
+
class A {
def foo(a: Int) = 0
}
diff --git a/tests/untried/pos/t2945.scala b/tests/pending/pos/t2945.scala
index 0379e9ba1..54f0a7724 100644
--- a/tests/untried/pos/t2945.scala
+++ b/tests/pending/pos/t2945.scala
@@ -1,9 +1,9 @@
object Foo {
def test(s: String) = {
(s: Seq[Char]) match {
- case Seq('f', 'o', 'o', ' ', rest1 @ _*) =>
+ case Seq('f', 'o', 'o', ' ', rest1: _*) =>
rest1
- case Seq('b', 'a', 'r', ' ', ' ', rest2 @ _*) =>
+ case Seq('b', 'a', 'r', ' ', ' ', rest2: _*) =>
rest2
case _ =>
s
diff --git a/tests/pos/implicitonSelect.scala b/tests/pos/implicitonSelect.scala
new file mode 100644
index 000000000..4f5f90ada
--- /dev/null
+++ b/tests/pos/implicitonSelect.scala
@@ -0,0 +1,8 @@
+object test {
+ class A
+ class B
+ implicit def a2b(x: A): B = new B
+ class ARef { val a: A = new A }
+ val x = new ARef
+ val b: B = x.a
+}
diff --git a/tests/pos/resultGuidesInference.scala b/tests/pos/resultGuidesInference.scala
new file mode 100644
index 000000000..4e02504e0
--- /dev/null
+++ b/tests/pos/resultGuidesInference.scala
@@ -0,0 +1,7 @@
+object test {
+
+ def foo[T](x: T => T): Array[T] = ???
+
+ val x: Array[Int] = foo(x => x)
+
+}
diff --git a/tests/new/t2405.scala b/tests/pos/t2405.scala
index 224b2ce83..224b2ce83 100644
--- a/tests/new/t2405.scala
+++ b/tests/pos/t2405.scala
diff --git a/tests/new/t2421.scala b/tests/pos/t2421.scala
index 2544a1cb3..2544a1cb3 100644
--- a/tests/new/t2421.scala
+++ b/tests/pos/t2421.scala
diff --git a/tests/new/t2421_delitedsl.scala b/tests/pos/t2421_delitedsl.scala
index 554702a03..554702a03 100644
--- a/tests/new/t2421_delitedsl.scala
+++ b/tests/pos/t2421_delitedsl.scala
diff --git a/tests/new/t2421b_pos.scala b/tests/pos/t2421b_pos.scala
index 679b8a8d6..679b8a8d6 100644
--- a/tests/new/t2421b_pos.scala
+++ b/tests/pos/t2421b_pos.scala
diff --git a/tests/new/t2421c.scala b/tests/pos/t2421c.scala
index bd24cacd7..bd24cacd7 100644
--- a/tests/new/t2421c.scala
+++ b/tests/pos/t2421c.scala
diff --git a/tests/new/t2425.scala b/tests/pos/t2425.scala
index 477d5467a..477d5467a 100755
--- a/tests/new/t2425.scala
+++ b/tests/pos/t2425.scala
diff --git a/tests/new/t2435.scala b/tests/pos/t2435.scala
index 697e9e1f2..697e9e1f2 100644
--- a/tests/new/t2435.scala
+++ b/tests/pos/t2435.scala
diff --git a/tests/new/t2441pos.scala b/tests/pos/t2441pos.scala
index 25eb2232c..25eb2232c 100644
--- a/tests/new/t2441pos.scala
+++ b/tests/pos/t2441pos.scala
diff --git a/tests/new/t2444.scala b/tests/pos/t2444.scala
index fac1e95d0..fac1e95d0 100644
--- a/tests/new/t2444.scala
+++ b/tests/pos/t2444.scala
diff --git a/tests/new/t245.scala b/tests/pos/t245.scala
index 570ac4178..570ac4178 100644
--- a/tests/new/t245.scala
+++ b/tests/pos/t245.scala
diff --git a/tests/pending/pos/t2454.scala b/tests/pos/t2454.scala
index 00f2e6f67..00f2e6f67 100644
--- a/tests/pending/pos/t2454.scala
+++ b/tests/pos/t2454.scala
diff --git a/tests/new/t247.scala b/tests/pos/t247.scala
index fdcafeb2c..fdcafeb2c 100644
--- a/tests/new/t247.scala
+++ b/tests/pos/t247.scala
diff --git a/tests/new/t2484.scala b/tests/pos/t2484.scala
index 15165c247..15165c247 100755
--- a/tests/new/t2484.scala
+++ b/tests/pos/t2484.scala
diff --git a/tests/new/t2486.scala b/tests/pos/t2486.scala
index 69fe4c127..69fe4c127 100644
--- a/tests/new/t2486.scala
+++ b/tests/pos/t2486.scala
diff --git a/tests/untried/pos/t2500.scala b/tests/pos/t2500.scala
index d0ff99a93..d0ff99a93 100644
--- a/tests/untried/pos/t2500.scala
+++ b/tests/pos/t2500.scala
diff --git a/tests/untried/pos/t2504.scala b/tests/pos/t2504.scala
index 67f822685..72117174c 100755
--- a/tests/untried/pos/t2504.scala
+++ b/tests/pos/t2504.scala
@@ -1,4 +1,5 @@
object Test {
+ val zs = Array("abc")
val ys: Iterable[_] = Array("abc")
val xs = Array("abc")
xs sameElements Array("abc")
diff --git a/tests/untried/pos/t252.scala b/tests/pos/t252.scala
index d51b5511e..d51b5511e 100644
--- a/tests/untried/pos/t252.scala
+++ b/tests/pos/t252.scala
diff --git a/tests/untried/pos/t2545.scala b/tests/pos/t2545.scala
index 6ad994223..6ad994223 100755
--- a/tests/untried/pos/t2545.scala
+++ b/tests/pos/t2545.scala
diff --git a/tests/untried/pos/t2591.scala b/tests/pos/t2591.scala
index 47ae551bf..47ae551bf 100644
--- a/tests/untried/pos/t2591.scala
+++ b/tests/pos/t2591.scala
diff --git a/tests/pos/t2610.scala b/tests/pos/t2610.scala
new file mode 100644
index 000000000..8a82b4a72
--- /dev/null
+++ b/tests/pos/t2610.scala
@@ -0,0 +1,17 @@
+package mada; package defects; package tests
+
+package object bbb {
+ def bar = ()
+ aaa.foo // value foo is not a member of package mada.defects.tests.aaa
+}
+
+package object aaa {
+ def foo = ()
+}
+
+/* compiles successfully if placed here..
+package object bbb {
+ def bar = ()
+ aaa.foo // value foo is not a member of package mada.defects.tests.aaa
+}
+*/
diff --git a/tests/pos/t2619.scala b/tests/pos/t2619.scala
new file mode 100644
index 000000000..283d93bf2
--- /dev/null
+++ b/tests/pos/t2619.scala
@@ -0,0 +1,80 @@
+abstract class F {
+ final def apply(x: Int): AnyRef = null
+}
+abstract class AbstractModule {
+ def as: List[AnyRef]
+ def ms: List[AbstractModule]
+ def fs: List[F] = Nil
+ def rs(x: Int): List[AnyRef] = fs.map(_(x))
+}
+abstract class ModuleType1 extends AbstractModule {}
+abstract class ModuleType2 extends AbstractModule {}
+
+object ModuleAE extends ModuleType1 {
+ def as = Nil
+ def ms = Nil
+}
+object ModuleAF extends ModuleType2 {
+ def as = Nil
+ def ms = List(ModuleAE)
+}
+object ModuleAG extends ModuleType1 {
+ def as = List("")
+ def ms = Nil
+}
+object ModuleAI extends ModuleType1 {
+ def as = Nil
+ def ms = List(ModuleAE)
+}
+object ModuleAK extends ModuleType2 {
+ def as = Nil
+ def ms = List(ModuleAF)
+}
+object ModuleAL extends ModuleType1 {
+ def as = Nil
+ def ms = List(
+ ModuleAG,
+ ModuleAI
+ )
+}
+object ModuleAM extends ModuleType1 {
+ def as = Nil
+ def ms = List(
+ ModuleAL,
+ ModuleAE
+ ) ::: List(ModuleAK)
+}
+object ModuleBE extends ModuleType1 {
+ def as = Nil
+ def ms = Nil
+}
+object ModuleBF extends ModuleType2 {
+ def as = Nil
+ def ms = List(ModuleBE)
+}
+object ModuleBG extends ModuleType1 {
+ def as = List("")
+ def ms = Nil
+}
+object ModuleBI extends ModuleType1 {
+ def as = Nil
+ def ms = List(ModuleBE)
+}
+object ModuleBK extends ModuleType2 {
+ def as = Nil
+ def ms = List(ModuleBF)
+}
+object ModuleBL extends ModuleType1 {
+ def as = Nil
+ def ms = List(
+ ModuleBG,
+ ModuleBI
+ )
+}
+object ModuleBM extends ModuleType1 {
+ def as = Nil
+ def ms = List(
+ ModuleBL,
+ ModuleBE
+ ) ::: List(ModuleBK)
+}
diff --git a/tests/pos/t262.scala b/tests/pos/t262.scala
new file mode 100644
index 000000000..ec6187b36
--- /dev/null
+++ b/tests/pos/t262.scala
@@ -0,0 +1,14 @@
+object O {
+ abstract class A {
+ def f:A;
+ }
+ class B extends A {
+ def f = if(1 == 2) new C else new D;
+ }
+ class C extends A {
+ def f = this;
+ }
+ class D extends A {
+ def f = this;
+ }
+}
diff --git a/tests/pos/t2624.scala b/tests/pos/t2624.scala
new file mode 100644
index 000000000..76f0e3036
--- /dev/null
+++ b/tests/pos/t2624.scala
@@ -0,0 +1,4 @@
+object Test {
+ List(1).map(identity(_))
+ List(1).map(identity) // this didn't typecheck before the fix
+}
diff --git a/tests/pos/t2635.scala b/tests/pos/t2635.scala
new file mode 100755
index 000000000..7cd553135
--- /dev/null
+++ b/tests/pos/t2635.scala
@@ -0,0 +1,16 @@
+abstract class Base
+
+object Test
+{
+ def run(c: Class[_ <: Base]): Unit = {
+ }
+
+ def main(args: Array[String]): Unit =
+ {
+ val sc: Option[Class[_ <: Base]] = Some(classOf[Base])
+ sc match {
+ case Some(c) => run(c)
+ case None =>
+ }
+ }
+}
diff --git a/tests/pos/t2660.scala b/tests/pos/t2660.scala
new file mode 100644
index 000000000..94a40f740
--- /dev/null
+++ b/tests/pos/t2660.scala
@@ -0,0 +1,25 @@
+package hoho
+
+class G
+
+class H extends G
+
+class A[T](x: T) {
+
+ def this(y: G, z: T) = {
+ this(z)
+ print(1)
+ }
+
+ def this(z: H, h: T) = {
+ this(h)
+ print(2)
+ }
+}
+
+object T {
+ def main(args: Array[String]): Unit = {
+ implicit def g2h(g: G): H = new H
+ new A[Int](new H, 23)
+ }
+}
diff --git a/tests/pos/t2664.scala b/tests/pos/t2664.scala
new file mode 100644
index 000000000..7b667d010
--- /dev/null
+++ b/tests/pos/t2664.scala
@@ -0,0 +1,9 @@
+package pkg1 {
+ class C {
+ private[pkg1] def foo: Int = 1
+ }
+
+ trait T extends C {
+ private[pkg1] abstract override def foo = super.foo + 1
+ }
+}
diff --git a/tests/pos/t2665.scala b/tests/pos/t2665.scala
new file mode 100644
index 000000000..e46453534
--- /dev/null
+++ b/tests/pos/t2665.scala
@@ -0,0 +1,3 @@
+object Test {
+ val x: Unit = Array("")
+}
diff --git a/tests/pos/t2667.scala b/tests/pos/t2667.scala
new file mode 100644
index 000000000..7f1f36f00
--- /dev/null
+++ b/tests/pos/t2667.scala
@@ -0,0 +1,6 @@
+object A {
+ def foo(x: Int, y: Int*): Int = 45
+ def foo[T](x: T*): Int = 55
+
+ val x: Unit = foo(23, 23f)
+}
diff --git a/tests/pos/t2669.scala b/tests/pos/t2669.scala
new file mode 100644
index 000000000..72e931178
--- /dev/null
+++ b/tests/pos/t2669.scala
@@ -0,0 +1,28 @@
+// #2629, #2639, #2669
+object Test2669 {
+
+ def test[T](l: java.util.ArrayList[_ <: T]) = 1
+ test(new java.util.ArrayList[String]())
+
+}
+
+import java.util.ArrayList
+
+object Test2629 {
+ def main(args: Array[String]): Unit = {
+ val l = new ArrayList[String](1)
+ val m = new ArrayList(l)
+
+ println(l.size)
+ println(m.size)
+ }
+}
+
+
+import java.util.Vector
+
+// scalac cannot detect lack of type params, but then throws AssertionError later:
+class TVector2639 {
+ val b = new Vector // this line passed without error detected
+ val a = new Vector(1) // this line caused throwing AssertionError when scalac
+}
diff --git a/tests/pos/t267.scala b/tests/pos/t267.scala
new file mode 100644
index 000000000..7e5876eae
--- /dev/null
+++ b/tests/pos/t267.scala
@@ -0,0 +1,55 @@
+package expAbstractData
+
+/** A base class consisting of
+ * - a root trait (i.e. abstract class) `Exp' with an `eval' function
+ * - an abstract type `exp' bounded by `Exp'
+ * - a concrete instance class `Num' of `Exp' for numeric literals
+ */
+trait Base {
+ type exp <: Exp
+
+ trait Exp {
+ def eval: Int
+ }
+ class Num(v: Int) extends Exp { self: exp =>
+ val value = v
+ def eval = value
+ }
+}
+
+object testBase extends App with Base {
+ type exp = Exp
+ val term = new Num(2);
+ Console.println(term.eval)
+}
+
+/** Data extension: An extension of `Base' with `Plus' expressions
+ */
+trait BasePlus extends Base {
+ class Plus(l: exp, r: exp) extends Exp { self: exp =>
+ val left = l
+ val right = r
+ def eval = left.eval + right.eval
+ }
+}
+
+/** Operation extension: An extension of `Base' with 'show' methods.
+ */
+trait Show extends Base {
+ type exp <: Exp1
+
+ trait Exp1 extends Exp {
+ def show: String
+ }
+ class Num1(v: Int) extends Num(v) with Exp1 { self: exp with Num1 =>
+ def show = value.toString()
+ }
+}
+
+/** Operation extension: An extension of `BasePlus' with 'show' methods.
+ */
+trait ShowPlus extends BasePlus with Show {
+ class Plus1(l: exp, r: exp) extends Plus(l, r) with Exp1 { self: exp with Plus1 =>
+ def show = left.show + " + " + right.show
+ }
+}
diff --git a/tests/pos/t2683.scala b/tests/pos/t2683.scala
new file mode 100755
index 000000000..4ba34b554
--- /dev/null
+++ b/tests/pos/t2683.scala
@@ -0,0 +1,7 @@
+class A
+class B extends A
+
+object Test {
+ val c: Class[_ <: A] = Class.forName("B").asSubclass(classOf[A])
+ val x: Option[Class[_ <: A]] = Some(3).map { case _ => c }
+}
diff --git a/tests/pos/t2691.scala b/tests/pos/t2691.scala
new file mode 100644
index 000000000..5f0ddd122
--- /dev/null
+++ b/tests/pos/t2691.scala
@@ -0,0 +1,16 @@
+object Breakdown {
+ def unapplySeq(x: Int): Some[List[String]] = Some(List("", "there"))
+}
+object Test {
+ 42 match {
+ case Breakdown("") => // needed to trigger bug
+ case Breakdown("", who) => println ("hello " + who)
+ }
+}
+object Test2 {
+ 42 match {
+ case Breakdown("") => // needed to trigger bug
+ case Breakdown("foo") => // needed to trigger bug
+ case Breakdown("", who) => println ("hello " + who)
+ }
+}
diff --git a/tests/pos/t2698.scala b/tests/pos/t2698.scala
new file mode 100644
index 000000000..bce02e48b
--- /dev/null
+++ b/tests/pos/t2698.scala
@@ -0,0 +1,14 @@
+class WordExp {
+ abstract class Label
+ type _labelT <: Label
+}
+
+import scala.collection._
+
+abstract class S2 {
+ val lang: WordExp
+ type __labelT = lang._labelT
+
+ var deltaq: Array[__labelT] = _
+ def delta1 = immutable.Map(deltaq.zipWithIndex: _*)
+}
diff --git a/tests/untried/pos/t2708.scala b/tests/pos/t2708.scala
index 19485bf4c..19485bf4c 100644
--- a/tests/untried/pos/t2708.scala
+++ b/tests/pos/t2708.scala
diff --git a/tests/untried/pos/t2726/SQLBuilder_1.scala b/tests/pos/t2726/SQLBuilder_1.scala
index 8d07a8826..8d07a8826 100644
--- a/tests/untried/pos/t2726/SQLBuilder_1.scala
+++ b/tests/pos/t2726/SQLBuilder_1.scala
diff --git a/tests/untried/pos/t2726/t2726_2.scala b/tests/pos/t2726/t2726_2.scala
index e738143ae..e738143ae 100644
--- a/tests/untried/pos/t2726/t2726_2.scala
+++ b/tests/pos/t2726/t2726_2.scala
diff --git a/tests/untried/pos/t2741/2741_1.scala b/tests/pos/t2741/2741_1.scala
index d9d04f7ab..d9d04f7ab 100644
--- a/tests/untried/pos/t2741/2741_1.scala
+++ b/tests/pos/t2741/2741_1.scala
diff --git a/tests/untried/pos/t2741/2741_2.scala b/tests/pos/t2741/2741_2.scala
index a9fd9d7d0..a9fd9d7d0 100644
--- a/tests/untried/pos/t2741/2741_2.scala
+++ b/tests/pos/t2741/2741_2.scala
diff --git a/tests/untried/pos/t2794.scala b/tests/pos/t2794.scala
index a17edf8cb..a17edf8cb 100644
--- a/tests/untried/pos/t2794.scala
+++ b/tests/pos/t2794.scala
diff --git a/tests/untried/pos/t2797.scala b/tests/pos/t2797.scala
index cf579d8de..cf579d8de 100644
--- a/tests/untried/pos/t2797.scala
+++ b/tests/pos/t2797.scala
diff --git a/tests/untried/pos/t2799.flags b/tests/pos/t2799.flags
index d1b831ea8..d1b831ea8 100644
--- a/tests/untried/pos/t2799.flags
+++ b/tests/pos/t2799.flags
diff --git a/tests/untried/pos/t2799.scala b/tests/pos/t2799.scala
index 7710cce26..7710cce26 100644
--- a/tests/untried/pos/t2799.scala
+++ b/tests/pos/t2799.scala
diff --git a/tests/untried/pos/t2809.scala b/tests/pos/t2809.scala
index 1f68b0b07..1f68b0b07 100644
--- a/tests/untried/pos/t2809.scala
+++ b/tests/pos/t2809.scala
diff --git a/tests/untried/pos/t2810.scala b/tests/pos/t2810.scala
index c85eca164..c85eca164 100644
--- a/tests/untried/pos/t2810.scala
+++ b/tests/pos/t2810.scala
diff --git a/tests/untried/pos/t284-pos.scala b/tests/pos/t284-pos.scala
index 40277e2db..40277e2db 100644
--- a/tests/untried/pos/t284-pos.scala
+++ b/tests/pos/t284-pos.scala
diff --git a/tests/untried/pos/t287.scala b/tests/pos/t287.scala
index 8e5e8831c..8e5e8831c 100644
--- a/tests/untried/pos/t287.scala
+++ b/tests/pos/t287.scala
diff --git a/tests/untried/pos/t289.scala b/tests/pos/t289.scala
index 96c0244df..96c0244df 100644
--- a/tests/untried/pos/t289.scala
+++ b/tests/pos/t289.scala
diff --git a/tests/untried/pos/t2910.scala b/tests/pos/t2910.scala
index f9f2c87a9..f9f2c87a9 100644
--- a/tests/untried/pos/t2910.scala
+++ b/tests/pos/t2910.scala
diff --git a/tests/untried/pos/t2939.scala b/tests/pos/t2939.scala
index 57dd52024..57dd52024 100644
--- a/tests/untried/pos/t2939.scala
+++ b/tests/pos/t2939.scala
diff --git a/tests/untried/pos/t295.scala b/tests/pos/t295.scala
index 22c7beff4..22c7beff4 100644
--- a/tests/untried/pos/t295.scala
+++ b/tests/pos/t295.scala
diff --git a/tests/untried/pos/t296.scala b/tests/pos/t296.scala
index 0c267a307..0c267a307 100644
--- a/tests/untried/pos/t296.scala
+++ b/tests/pos/t296.scala
diff --git a/tests/untried/pos/t2973.scala b/tests/pos/t2973.scala
index f5dde856d..f5dde856d 100644
--- a/tests/untried/pos/t2973.scala
+++ b/tests/pos/t2973.scala
diff --git a/tests/pos/test.scala b/tests/pos/test.scala
deleted file mode 100644
index 71fa1b1d9..000000000
--- a/tests/pos/test.scala
+++ /dev/null
@@ -1,6 +0,0 @@
-object test {
-
- val m = new java.util.HashMap[String, String]
- m.size
-
-} \ No newline at end of file
diff --git a/tests/pos/tuplePatDef.scala b/tests/pos/tuplePatDef.scala
new file mode 100644
index 000000000..22f8f8e7d
--- /dev/null
+++ b/tests/pos/tuplePatDef.scala
@@ -0,0 +1,4 @@
+
+object Test {
+ val (x,y): (String, Int) = null
+}
diff --git a/tests/pos/tycons.scala b/tests/pos/tycons.scala
new file mode 100644
index 000000000..f138c78be
--- /dev/null
+++ b/tests/pos/tycons.scala
@@ -0,0 +1,22 @@
+class TypeConstructor {
+ type TypeArg
+}
+
+trait List[+T] extends TypeConstructor { type TypeArg <: T }
+
+trait Set[T] extends TypeConstructor { type TypeArg <: T }
+
+object obj extends List[Number] with Set[Exception] {
+ val x: TypeArg = ???
+ val n: Number = x
+ val e: Exception = x
+}
+
+class Functor[F <: TypeConstructor] {
+ def map[A, B](f: F { type TypeArg <: A }): F { type TypeArg <: B }
+}
+
+implicit object ListFunctor extends Functor[List] {
+ def map[A, B](f: List[A]): List[B] = ???
+}
+
diff --git a/tests/untried/pos/t2994b.scala b/tests/untried/pos/t2994b.scala
deleted file mode 100644
index 8b5eb9692..000000000
--- a/tests/untried/pos/t2994b.scala
+++ /dev/null
@@ -1,7 +0,0 @@
-object Test {
- trait Bar[X[_]]
- trait Baz[S[_] <: Bar[S]] {
- type Apply[T]
- }
- trait Foo[V[_] <: Bar[V]] extends Bar[Baz[V]#Apply]
-}