Skip to content

Fix #241 #1000

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 69 commits into from
Dec 15, 2015
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
cf79403
Drop requirement that an isRef type cannot be refined.
odersky Nov 30, 2015
4c8db87
Don't count partial applications as applications.
odersky Dec 1, 2015
df00eb1
Disallow existentially bound parameters as type parameters
odersky Dec 1, 2015
0fde4b4
Change hk naming scheme
odersky Dec 2, 2015
f89b562
Add missing type params in test
odersky Dec 2, 2015
7eeb565
Extractors and other new functionality for type applications
odersky Dec 2, 2015
e63f058
Use typeapp extractors for printing
odersky Dec 2, 2015
e14be2d
Fix adaptIfHK and drop rawTypeParams
odersky Dec 2, 2015
67d2833
Drop redundant check in beta reduce
odersky Dec 2, 2015
2abcd02
Use new adaptArgs for Scala2Unpickler
odersky Dec 2, 2015
73bf06b
More uses of adaptIfHK
odersky Dec 2, 2015
91a865c
Base Application extractor on classSymbols
odersky Dec 2, 2015
261087a
Fix problem with printing lambdas.
odersky Dec 2, 2015
56e63ed
Don't recognize type bounds as lambda abstractions
odersky Dec 3, 2015
05c0e55
Fix bug computing typeParams for hk types
odersky Dec 3, 2015
8db7a9b
Fix bug computing typeParams for hk types
odersky Dec 3, 2015
130c24c
Fix to TypeLambda over with a TypeBounds body
odersky Dec 3, 2015
1fe3310
Fixes to TypeLambda and EtaExpansion extractors.
odersky Dec 3, 2015
8cd50f7
Fully type annotate Printers
odersky Dec 3, 2015
dec21f5
Better diagnostics for applyOverloaded.
odersky Dec 4, 2015
f8d82c2
Switch to new hk scheme.
odersky Dec 4, 2015
d186a33
Reset constraint when one of several implicit arguments is not found.
odersky Dec 5, 2015
56dd29d
Fix printing of type lambdas
odersky Dec 5, 2015
6519309
Allow for F-bounded bounds in TypeLambda
odersky Dec 5, 2015
50d2652
Be DRY betweeen EtaExpand and LambdaAbstract
odersky Dec 6, 2015
f6d1153
Avoid false positives when extracting AppliedType
odersky Dec 6, 2015
378b96f
Fix tasty test failures
odersky Dec 6, 2015
b8c6e73
Move failing test to pending
odersky Dec 6, 2015
7f6decf
Code and documentation cleanups
odersky Dec 6, 2015
169c8dc
Cleanup of RefinedType subtype comparison.
odersky Dec 6, 2015
1c77b03
Fix TypeLambda extractor.
odersky Dec 10, 2015
fd44a17
Disallow hk type parameters in lower bounds.
odersky Dec 11, 2015
6cb2a3b
Remove extraneous match
odersky Dec 11, 2015
b8e05d5
Add isBottomType/Class tests to Definitions
odersky Dec 11, 2015
88f24ef
Allow bottom types as hk type arguments
odersky Dec 11, 2015
b350d20
Perform variance adaptation only when needed in isSubType
odersky Dec 13, 2015
2703543
In isSubType, follow aliases only if prefix is a path.
odersky Dec 13, 2015
dba4b94
Avoid cycle when computing sets
odersky Dec 13, 2015
b593958
Better explanation for adaptHkVariances
odersky Dec 13, 2015
95098ba
Shortcut in derivesFrom for high bound Any.
odersky Dec 13, 2015
8a9e89a
Allow deep subtype for sets and related code in dotty/transform.
odersky Dec 13, 2015
886b74d
Remove redundant type parameter in testLifted
odersky Dec 7, 2015
ef66db2
Rename TypeArgument -> BaseTypeArg flag.
odersky Dec 7, 2015
083b949
Make all arg bindings have flag BaseTypeArg.
odersky Dec 7, 2015
25f3858
Disregard BaseTypeArg parameters when variance checking.
odersky Dec 7, 2015
9eee92f
Fix of too strict variance checking.
odersky Dec 7, 2015
611bf86
Add whitelist entries which now work
odersky Dec 7, 2015
9b2d9b2
Remove stray assignment
odersky Dec 8, 2015
4900abc
Avoid unassigned type errors when typing curried functions.
odersky Dec 8, 2015
6c91684
Fix tricky bug coming up when compiling TraversableViewLike.
odersky Dec 8, 2015
ac99941
Do not report data races between symbols defined in class and its sel…
odersky Dec 8, 2015
8203177
Adaptations to checkSymAssign
odersky Dec 10, 2015
2a3f786
Fix sleeper bug in ParamForwarding
odersky Dec 10, 2015
f829cf8
Make some types of definitions symbolic
odersky Dec 10, 2015
db9d4f0
Add test case
odersky Dec 10, 2015
c4238b1
Drop redundant condition
odersky Dec 10, 2015
3476bab
Better diagnostics for clashing classes
odersky Dec 10, 2015
7cdbcdb
Convert super. prefixes of types to this.
odersky Dec 10, 2015
82f59af
Fix problem handling SuperTypes in asSeenFrom
odersky Dec 11, 2015
3bbc2bf
Better diagnosis for cyclic references caused by class clashes.
odersky Dec 11, 2015
44782f2
Add new whitelists tests.
odersky Dec 11, 2015
a0b2972
Improve printing of overloaded denotations
odersky Nov 16, 2015
0a19b0b
Only select parameterless get methods in unapplys.
odersky Nov 16, 2015
21948a5
Generalize overriding checking from isDefined
odersky Nov 16, 2015
8103c64
Add comments to whitelist with assignments for further action.
odersky Dec 11, 2015
86e35e4
Use symbolic refs when testing whether a TypeBounds contains a ClassInfo
odersky Dec 14, 2015
503011f
Check types for overriding conditions.
odersky Dec 14, 2015
3a031f5
Change <:< to overrides
odersky Dec 15, 2015
7e8f401
More tweaks to override checks.
odersky Dec 15, 2015
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions src/dotty/tools/dotc/ast/Desugar.scala
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,13 @@ object desugar {
/** Info of a variable in a pattern: The named tree and its type */
private type VarInfo = (NameTree, Tree)

/** Names of methods that are added unconditionally to case classes */
def isDesugaredCaseClassMethodName(name: Name)(implicit ctx: Context) =
name == nme.isDefined ||
name == nme.copy ||
name == nme.productArity ||
name.isSelectorName

// ----- DerivedTypeTrees -----------------------------------

class SetterParamTree extends DerivedTypeTree {
Expand Down
25 changes: 16 additions & 9 deletions src/dotty/tools/dotc/ast/tpd.scala
Original file line number Diff line number Diff line change
Expand Up @@ -845,15 +845,22 @@ object tpd extends Trees.Instance[Type] with TypedTreeInfo {
def applyOverloaded(receiver: Tree, method: TermName, args: List[Tree], targs: List[Type], expectedType: Type, isAnnotConstructor: Boolean = false)(implicit ctx: Context): Tree = {
val typer = ctx.typer
val proto = new FunProtoTyped(args, expectedType, typer)
val alts = receiver.tpe.member(method).alternatives.map(_.termRef)

val alternatives = ctx.typer.resolveOverloaded(alts, proto, Nil)
assert(alternatives.size == 1,
i"multiple overloads available for $method on ${receiver.tpe.widenDealias} with targs: $targs, args: $args and expectedType: $expectedType." +
i" isAnnotConstructor = $isAnnotConstructor.\n" +
i"alternatives: $alternatives") // this is parsed from bytecode tree. there's nothing user can do about it

val selected = alternatives.head
val denot = receiver.tpe.member(method)
assert(denot.exists, i"no member $receiver . $method, members = ${receiver.tpe.decls}")
val selected =
if (denot.isOverloaded) {
val allAlts = denot.alternatives.map(_.termRef)
val alternatives =
ctx.typer.resolveOverloaded(allAlts, proto, Nil)
assert(alternatives.size == 1,
i"${if (alternatives.isEmpty) "no" else "multiple"} overloads available for " +
i"$method on ${receiver.tpe.widenDealias} with targs: $targs, args: $args and expectedType: $expectedType." +
i" isAnnotConstructor = $isAnnotConstructor.\n" +
i"all alternatives: ${allAlts.map(_.symbol.showDcl).mkString(", ")}\n" +
i"matching alternatives: ${alternatives.map(_.symbol.showDcl).mkString(", ")}.") // this is parsed from bytecode tree. there's nothing user can do about it
alternatives.head
}
else denot.asSingleDenotation.termRef
val fun = receiver
.select(TermRef.withSig(receiver.tpe, selected.termSymbol.asTerm))
.appliedToTypes(targs)
Expand Down
18 changes: 9 additions & 9 deletions src/dotty/tools/dotc/config/Printers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ object Printers {
val implicitsDetailed: Printer = noPrinter
val subtyping: Printer = noPrinter
val unapp: Printer = noPrinter
val gadts = noPrinter
val hk = noPrinter
val variances = noPrinter
val incremental = noPrinter
val config = noPrinter
val transforms = noPrinter
val completions = noPrinter
val cyclicErrors = noPrinter
val pickling = noPrinter
val gadts: Printer = noPrinter
val hk: Printer = noPrinter
val variances: Printer = noPrinter
val incremental: Printer = noPrinter
val config: Printer = noPrinter
val transforms: Printer = noPrinter
val completions: Printer = noPrinter
val cyclicErrors: Printer = noPrinter
val pickling: Printer = noPrinter
}
10 changes: 10 additions & 0 deletions src/dotty/tools/dotc/core/ConstraintHandling.scala
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,16 @@ trait ConstraintHandling {
}
}

/** Instantiate `param` to `tp` if the constraint stays satisfiable */
protected def tryInstantiate(param: PolyParam, tp: Type): Boolean = {
val saved = constraint
constraint =
if (addConstraint(param, tp, fromBelow = true) &&
addConstraint(param, tp, fromBelow = false)) constraint.replace(param, tp)
else saved
constraint ne saved
}

/** Check that constraint is fully propagated. See comment in Config.checkConstraintsPropagated */
def checkPropagated(msg: => String)(result: Boolean): Boolean = {
if (Config.checkConstraintsPropagated && result && addConstraintInvocations == 0) {
Expand Down
16 changes: 11 additions & 5 deletions src/dotty/tools/dotc/core/Definitions.scala
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,12 @@ class Definitions {
name.startsWith(prefix) && name.drop(prefix.length).forall(_.isDigit)
}

def isBottomClass(cls: Symbol) = cls == NothingClass || cls == NullClass
def isBottomType(tp: Type) = tp match {
case tp: TypeRef => isBottomClass(tp.symbol)
case _ => false
}

def isFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.Function)
def isAbstractFunctionClass(cls: Symbol) = isVarArityClass(cls, tpnme.AbstractFunction)
def isTupleClass(cls: Symbol) = isVarArityClass(cls, tpnme.Tuple)
Expand Down Expand Up @@ -642,9 +648,9 @@ class Definitions {
* to be the type parameters of a higher-kided type). This is a class symbol that
* would be generated by the following schema.
*
* class LambdaXYZ extends Object with P1 with ... with Pn {
* type v_1 $hk$Arg0; ...; type v_N $hk$ArgN;
* type Apply
* trait LambdaXYZ extends Object with P1 with ... with Pn {
* type v_1 hk$0; ...; type v_N hk$N;
* type +$Apply
* }
*
* Here:
Expand All @@ -669,7 +675,7 @@ class Definitions {
val cls = denot.asClass.classSymbol
val paramDecls = newScope
for (i <- 0 until vcs.length)
newTypeParam(cls, tpnme.LambdaArgName(i), varianceFlags(vcs(i)), paramDecls)
newTypeParam(cls, tpnme.hkArg(i), varianceFlags(vcs(i)), paramDecls)
newTypeField(cls, tpnme.hkApply, Covariant, paramDecls)
val parentTraitRefs =
for (i <- 0 until vcs.length if vcs(i) != 0)
Expand All @@ -679,7 +685,7 @@ class Definitions {
}
}

val traitName = tpnme.LambdaTraitName(vcs)
val traitName = tpnme.hkLambda(vcs)

def createTrait = {
val cls = newClassSymbol(
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Denotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ object Denotations {
info1 // follow Scala2 linearization -
// compare with way merge is performed in SymDenotation#computeMembersNamed
else
throw new MergeError(s"${ex.getMessage} as members of type ${pre.show}")
throw new MergeError(s"${ex.getMessage} as members of type ${pre.show}", ex.tp1, ex.tp2)
}
new JointRefDenotation(sym, jointInfo, denot1.validFor & denot2.validFor)
}
Expand Down
15 changes: 10 additions & 5 deletions src/dotty/tools/dotc/core/Flags.scala
Original file line number Diff line number Diff line change
Expand Up @@ -306,10 +306,12 @@ object Flags {
/** A case parameter accessor */
final val CaseAccessor = termFlag(25, "<caseaccessor>")

/** An type parameter which is an alias for some other (non-visible) type parameter */
final val TypeArgument = typeFlag(25, "<type-param-inst>")
/** A binding for a type parameter of a base class or trait.
* TODO: Replace with combination of isType, ExpandedName, and Override?
*/
final val BaseTypeArg = typeFlag(25, "<basetypearg>")

final val CaseAccessorOrTypeArgument = CaseAccessor.toCommonFlags
final val CaseAccessorOrBaseTypeArg = CaseAccessor.toCommonFlags

/** A super accessor */
final val SuperAccessor = termFlag(26, "<superaccessor>")
Expand Down Expand Up @@ -446,7 +448,7 @@ object Flags {
final val FromStartFlags =
AccessFlags | Module | Package | Deferred | Final | MethodOrHKCommon | Param | ParamAccessor | Scala2ExistentialCommon |
InSuperCall | Touched | JavaStatic | CovariantOrOuter | ContravariantOrLabel | ExpandedName | AccessorOrSealed |
CaseAccessorOrTypeArgument | Fresh | Frozen | Erroneous | ImplicitCommon | Permanent |
CaseAccessorOrBaseTypeArg | Fresh | Frozen | Erroneous | ImplicitCommon | Permanent |
LazyOrTrait | SuperAccessorOrScala2x | SelfNameOrImplClass

assert(FromStartFlags.isTermFlags && FromStartFlags.isTypeFlags)
Expand Down Expand Up @@ -545,7 +547,7 @@ object Flags {
final val TypeParamOrAccessor = TypeParam | TypeParamAccessor

/** If symbol of a type alias has these flags, prefer the alias */
final val AliasPreferred = TypeParam | TypeArgument | ExpandedName
final val AliasPreferred = TypeParam | BaseTypeArg | ExpandedName

/** A covariant type parameter instance */
final val LocalCovariant = allOf(Local, Covariant)
Expand Down Expand Up @@ -583,6 +585,9 @@ object Flags {
/** A private[this] parameter accessor */
final val PrivateLocalParamAccessor = allOf(Private, Local, ParamAccessor)

/** A parameter forwarder */
final val ParamForwarder = allOf(Method, Stable, ParamAccessor)

/** A private[this] parameter */
final val PrivateLocalParam = allOf(Private, Local, Param)

Expand Down
16 changes: 10 additions & 6 deletions src/dotty/tools/dotc/core/NameOps.scala
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ object NameOps {
def isScala2LocalSuffix = name.endsWith(" ")
def isModuleVarName(name: Name): Boolean =
name.stripAnonNumberSuffix endsWith MODULE_VAR_SUFFIX
def isSelectorName = name.startsWith(" ") && name.tail.forall(_.isDigit)

/** Is name a variable name? */
def isVariableName: Boolean = name.length > 0 && {
Expand All @@ -99,19 +100,22 @@ object NameOps {
}

/** Is this the name of a higher-kinded type parameter of a Lambda? */
def isLambdaArgName =
def isHkArgName =
name.length > 0 &&
name.head == tpnme.LAMBDA_ARG_PREFIXhead &&
name.startsWith(tpnme.LAMBDA_ARG_PREFIX) && {
val digits = name.drop(tpnme.LAMBDA_ARG_PREFIX.length)
name.head == tpnme.hkArgPrefixHead &&
name.startsWith(tpnme.hkArgPrefix) && {
val digits = name.drop(tpnme.hkArgPrefixLength)
digits.length <= 4 && digits.forall(_.isDigit)
}

/** The index of the higher-kinded type parameter with this name.
* Pre: isLambdaArgName.
*/
def LambdaArgIndex: Int =
name.drop(tpnme.LAMBDA_ARG_PREFIX.length).toString.toInt
def hkArgIndex: Int =
name.drop(tpnme.hkArgPrefixLength).toString.toInt

def isLambdaTraitName(implicit ctx: Context): Boolean =
name.startsWith(tpnme.hkLambdaPrefix)

/** If the name ends with $nn where nn are
* all digits, strip the $ and the digits.
Expand Down
20 changes: 10 additions & 10 deletions src/dotty/tools/dotc/core/StdNames.scala
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,6 @@ object StdNames {
final val WILDCARD_STAR: N = "_*"
final val REIFY_TREECREATOR_PREFIX: N = "$treecreator"
final val REIFY_TYPECREATOR_PREFIX: N = "$typecreator"
final val LAMBDA_ARG_PREFIX: N = "hk$"
final val LAMBDA_ARG_PREFIXhead: Char = LAMBDA_ARG_PREFIX.head

final val AbstractFunction: N = "AbstractFunction"
final val Any: N = "Any"
Expand Down Expand Up @@ -314,15 +312,13 @@ object StdNames {

val AnnotatedType: N = "AnnotatedType"
val AppliedTypeTree: N = "AppliedTypeTree"
val hkApply: N = "$apply"
val ArrayAnnotArg: N = "ArrayAnnotArg"
val Constant: N = "Constant"
val ConstantType: N = "ConstantType"
val ExistentialTypeTree: N = "ExistentialTypeTree"
val Flag : N = "Flag"
val Ident: N = "Ident"
val Import: N = "Import"
val LambdaPrefix: N = "Lambda$"
val Literal: N = "Literal"
val LiteralAnnotArg: N = "LiteralAnnotArg"
val Modifiers: N = "Modifiers"
Expand Down Expand Up @@ -530,9 +526,14 @@ object StdNames {
val nothingRuntimeClass: N = "scala.runtime.Nothing$"
val nullRuntimeClass: N = "scala.runtime.Null$"


val synthSwitch: N = "$synthSwitch"

val hkApply: N = "$Apply"
val hkArgPrefix: N = "$hk"
val hkLambdaPrefix: N = "Lambda$"
val hkArgPrefixHead: Char = hkArgPrefix.head
val hkArgPrefixLength: Int = hkArgPrefix.length

// unencoded operators
object raw {
final val AMP : N = "&"
Expand Down Expand Up @@ -742,14 +743,13 @@ object StdNames {
def syntheticTypeParamNames(num: Int): List[TypeName] =
(0 until num).map(syntheticTypeParamName)(breakOut)

def LambdaTraitName(vcs: List[Int]): TypeName = LambdaPrefix ++ vcs.map(varianceSuffix).mkString
def LambdaArgName(n: Int) = LAMBDA_ARG_PREFIX ++ n.toString

final val Conforms = encode("<:<")
def hkLambda(vcs: List[Int]): TypeName = hkLambdaPrefix ++ vcs.map(varianceSuffix).mkString
def hkArg(n: Int): TypeName = hkArgPrefix ++ n.toString

def varianceSuffix(v: Int): Char = varianceSuffixes.charAt(v + 1)

val varianceSuffixes = "NIP"

final val Conforms = encode("<:<")
}

abstract class JavaNames[N <: Name] extends DefinedNames[N] {
Expand Down
3 changes: 1 addition & 2 deletions src/dotty/tools/dotc/core/SymDenotations.scala
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ object SymDenotations {
completions.println(i"${" " * indent}completing ${if (isType) "type" else "val"} $name")
indent += 1
}
indent += 1
if (myFlags is Touched) throw CyclicReference(this)
myFlags |= Touched

Expand Down Expand Up @@ -446,7 +445,7 @@ object SymDenotations {

/** is this symbol a trait representing a type lambda? */
final def isLambdaTrait(implicit ctx: Context): Boolean =
isClass && name.startsWith(tpnme.LambdaPrefix) && owner == defn.ScalaPackageClass
isClass && name.startsWith(tpnme.hkLambdaPrefix) && owner == defn.ScalaPackageClass

/** Is this symbol a package object or its module class? */
def isPackageObject(implicit ctx: Context): Boolean = {
Expand Down
2 changes: 1 addition & 1 deletion src/dotty/tools/dotc/core/Symbols.scala
Original file line number Diff line number Diff line change
Expand Up @@ -368,7 +368,7 @@ object Symbols {

type ThisName <: Name

//assert(_id != 30214)
//assert(id != 4285)

/** The last denotation of this symbol */
private[this] var lastDenot: SymDenotation = _
Expand Down
Loading