Skip to content

Commit 3a5026c

Browse files
committed
Big Cleanup
1 parent 1cec49a commit 3a5026c

File tree

4 files changed

+13
-59
lines changed

4 files changed

+13
-59
lines changed

TypesEverywhere.scala

Lines changed: 0 additions & 13 deletions
This file was deleted.

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2937,7 +2937,7 @@ object Parsers {
29372937

29382938
def recur(firstClause: Boolean, nparams: Int): List[List[TypeDef] | List[ValDef]] =
29392939
newLineOptWhenFollowedBy(LPAREN)
2940-
newLineOptWhenFollowedBy(LBRACKET) //I have doubts this works //TODO: test this
2940+
newLineOptWhenFollowedBy(LBRACKET)
29412941
if in.token == LPAREN then
29422942
val paramsStart = in.offset
29432943
val params = paramClause(
@@ -3468,7 +3468,7 @@ object Parsers {
34683468
argumentExprss(mkApply(Ident(nme.CONSTRUCTOR), argumentExprs()))
34693469
}
34703470

3471-
/** TypeDcl ::= id [TypeParamClause] {FunParamClause} TypeBounds [‘=’ Type] //TODO: change to {ParamClauses} ?
3471+
/** TypeDcl ::= id [TypeParamClause] {FunParamClause} TypeBounds [‘=’ Type]
34723472
*/
34733473
def typeDefOrDcl(start: Offset, mods: Modifiers): Tree = {
34743474
newLinesOpt()
@@ -3565,7 +3565,7 @@ object Parsers {
35653565
val tparams = typeParamClauseOpt(ParamOwner.Class)
35663566
val cmods = fromWithinClassConstr(constrModsOpt())
35673567
val vparamss = paramClauses(ofClass = true, ofCaseClass = isCaseClass)
3568-
makeConstructor(tparams, vparamss).withMods(cmods) //TODO: Reafactor to take List[List[ValDef] | List[TypeDef]]
3568+
makeConstructor(tparams, vparamss).withMods(cmods)
35693569
}
35703570

35713571
/** ConstrMods ::= {Annotation} [AccessModifier]
@@ -3654,7 +3654,7 @@ object Parsers {
36543654
}
36553655

36563656
/** GivenDef ::= [GivenSig] (AnnotType [‘=’ Expr] | StructuralInstance)
3657-
* GivenSig ::= [id] [DefTypeParamClause] {UsingParamClauses} ‘:’ //TODO: Change to {Params}
3657+
* GivenSig ::= [id] [DefTypeParamClause] {UsingParamClauses} ‘:’
36583658
*/
36593659
def givenDef(start: Offset, mods: Modifiers, givenMod: Mod) = atSpan(start, nameStart) {
36603660
var mods1 = addMod(mods, givenMod)
@@ -3702,7 +3702,7 @@ object Parsers {
37023702
}
37033703

37043704
/** Extension ::= ‘extension’ [DefTypeParamClause] {UsingParamClause} ‘(’ DefTermParam ‘)’
3705-
* {UsingParamClause} ExtMethods //TODO: Change to {Params} ?
3705+
* {UsingParamClause} ExtMethods
37063706
*/
37073707
def extension(): ExtMethods =
37083708
val start = in.skipToken()

compiler/src/dotty/tools/dotc/typer/Applications.scala

Lines changed: 6 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -404,9 +404,7 @@ trait Applications extends Compatibility {
404404
private var _ok = true
405405

406406
def ok: Boolean = _ok
407-
def ok_=(x: Boolean): Unit =
408-
//if !x then println("set ok to false")
409-
_ok = x
407+
def ok_=(x: Boolean): Unit = _ok = x
410408

411409
/** The function's type after widening and instantiating polytypes
412410
* with TypeParamRefs in constraint set
@@ -416,7 +414,6 @@ trait Applications extends Compatibility {
416414
t.widen match{
417415
case funType: MethodType => funType
418416
case funType: PolyType =>
419-
//rec(constrained(funType).resultType) //TODO: Could replace rec(etc) by etc.methType ?
420417
rec(instantiateWithTypeVars(funType))
421418
case tp => tp
422419
}
@@ -666,7 +663,6 @@ trait Applications extends Compatibility {
666663
defn.isFunctionType(argtpe1) && formal.match
667664
case SAMType(sam) => argtpe <:< sam.toFunctionType(isJava = formal.classSymbol.is(JavaDefined))
668665
case _ => false
669-
//println(s"argOK($arg,$formal) = ${isCompatible(argtpe, formal)}")
670666
isCompatible(argtpe, formal)
671667
// Only allow SAM-conversion to PartialFunction if implicit conversions
672668
// are enabled. This is necessary to avoid ambiguity between an overload
@@ -713,7 +709,6 @@ trait Applications extends Compatibility {
713709
*/
714710
class ApplicableToTrees(methRef: TermRef, args: List[Tree], resultType: Type, argMatch: ArgMatch)(using Context)
715711
extends TestApplication(methRef, methRef.widen, args, resultType, argMatch) {
716-
//println("ApplicableToTrees created")
717712
def argType(arg: Tree, formal: Type): Type =
718713
if untpd.isContextualClosure(arg) && defn.isContextFunctionType(formal) then arg.tpe
719714
else normalize(arg.tpe, formal)
@@ -1090,8 +1085,6 @@ trait Applications extends Compatibility {
10901085
val typedArgs = if (isNamed) typedNamedArgs(tree.args) else tree.args.mapconserve(typedType(_))
10911086
record("typedTypeApply")
10921087
typedExpr(tree.fun, PolyProto(typedArgs, pt)) match {
1093-
/* case _: TypeApply if !ctx.isAfterTyper => //TODO: assess removing this is okay
1094-
errorTree(tree, "illegal repeated type application") */
10951088
case typedFn =>
10961089
typedFn.tpe.widen match {
10971090
case pt: PolyType =>
@@ -1399,10 +1392,8 @@ trait Applications extends Compatibility {
13991392
* @param resultType The expected result type of the application
14001393
*/
14011394
def isApplicableMethodRef(methRef: TermRef, args: List[Tree], resultType: Type, keepConstraint: Boolean, argMatch: ArgMatch)(using Context): Boolean = {
1402-
//println("entered isApplicableMethodRef")
14031395
def isApp(using Context): Boolean =
14041396
new ApplicableToTrees(methRef, args, resultType, argMatch).success
1405-
//println(isApp) // check above ^
14061397
if (keepConstraint) isApp else explore(isApp)
14071398
}
14081399

@@ -1764,16 +1755,10 @@ trait Applications extends Compatibility {
17641755
* probability of pruning the search. result type comparisons are neither cheap nor
17651756
* do they prune much, on average.
17661757
*/
1767-
def adaptByResult(chosen: TermRef, alts: List[TermRef]) =
1768-
//println("entered adaptByResult")
1769-
//println(chosen.symbol.showDcl)
1770-
//println(alts.map(_.symbol.showDcl))
1771-
pt match {
1758+
def adaptByResult(chosen: TermRef, alts: List[TermRef]) = pt match {
17721759
case pt: FunProto if !explore(resultConforms(chosen.symbol, chosen, pt.resultType)) =>
1773-
//println("pt funproto")
17741760
val conformingAlts = alts.filterConserve(alt =>
17751761
(alt ne chosen) && explore(resultConforms(alt.symbol, alt, pt.resultType)))
1776-
//println(conformingAlts.map(_.symbol.showDcl))
17771762
conformingAlts match {
17781763
case Nil => chosen
17791764
case alt2 :: Nil => alt2
@@ -1787,7 +1772,6 @@ trait Applications extends Compatibility {
17871772
}
17881773

17891774
def resolve(alts: List[TermRef]): List[TermRef] =
1790-
//println("enter resolve")
17911775
pt match
17921776
case pt: FunProto =>
17931777
if pt.applyKind == ApplyKind.Using then
@@ -1798,18 +1782,11 @@ trait Applications extends Compatibility {
17981782
case _ =>
17991783

18001784
var found = withoutMode(Mode.ImplicitsEnabled)(resolveOverloaded1(alts, pt))
1801-
//println("found =")
1802-
//println(found.map(_.symbol.showDcl))
18031785
if found.isEmpty && ctx.mode.is(Mode.ImplicitsEnabled) then
1804-
//println("update found")
18051786
found = resolveOverloaded1(alts, pt)
18061787
found match
1807-
case alt :: Nil =>
1808-
//println("resolve1")
1809-
adaptByResult(alt, alts) :: Nil
1810-
case _ =>
1811-
//println("resolve2")
1812-
found
1788+
case alt :: Nil => adaptByResult(alt, alts) :: Nil
1789+
case _ => found
18131790
end resolve
18141791

18151792
/** Try an apply method, if
@@ -1857,9 +1834,6 @@ trait Applications extends Compatibility {
18571834
trace(i"resolve over $alts%, %, pt = $pt", typr, show = true) {
18581835
record(s"resolveOverloaded1", alts.length)
18591836

1860-
//println(pt.show)
1861-
//println(pt)
1862-
18631837
def isDetermined(alts: List[TermRef]) = alts.isEmpty || alts.tail.isEmpty
18641838

18651839
/** The shape of given tree as a type; cannot handle named arguments. */
@@ -1959,25 +1933,17 @@ trait Applications extends Compatibility {
19591933
record("resolveOverloaded.FunProto", alts.length)
19601934
val alts1 = narrowBySize(alts)
19611935
//report.log(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
1962-
//println(i"narrowed by size: ${alts1.map(_.symbol.showDcl)}%, %")
19631936
if isDetermined(alts1) then alts1
19641937
else
19651938
record("resolveOverloaded.narrowedBySize", alts1.length)
19661939
val alts2 = narrowByShapes(alts1)
19671940
//report.log(i"narrowed by shape: ${alts2.map(_.symbol.showDcl)}%, %")
1968-
//println(i"narrowed by shape: ${alts2.map(_.symbol.showDcl)}%, %")
19691941
if isDetermined(alts2)
1970-
then
1971-
//println("1")
1972-
//println(alts2.map(_.symbol.showDcl))
1973-
alts2
1942+
then alts2
19741943
else
19751944
record("resolveOverloaded.narrowedByShape", alts2.length)
19761945
pretypeArgs(alts2, pt)
1977-
val res = narrowByTrees(alts2, pt.typedArgs(normArg(alts2, _, _)), resultType)
1978-
//println("2")
1979-
//println(res.map(_.symbol.showDcl))
1980-
res
1946+
narrowByTrees(alts2, pt.typedArgs(normArg(alts2, _, _)), resultType)
19811947

19821948
case pt @ PolyProto(targs1, pt1) =>
19831949
val alts1 = alts.filterConserve(pt.canInstantiate)
Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
def f1[T][U](x: T, y: U): (T, U) = (x, y)
22
def f2[T](x: T)[U](y: U): (T, U) = (x, y)
3-
def f3[T, U][V](x: T): U = ???
3+
def f3[T, U][V](x: T): U = ???
4+
def f4[T](x: T)[U <: x.type](y: U): (T, U) = (x, y)

0 commit comments

Comments
 (0)