@@ -8,12 +8,13 @@ import com.intellij.psi._
8
8
import org .jetbrains .plugins .scala .lang .psi .api .base .ScFieldId
9
9
import org .jetbrains .plugins .scala .lang .psi .api .base .patterns .ScBindingPattern
10
10
import org .jetbrains .plugins .scala .lang .psi .api .statements .ScFunction
11
- import org .jetbrains .plugins .scala .lang .psi .api .statements .params .ScParameter
11
+ import org .jetbrains .plugins .scala .lang .psi .api .statements .params .{ ScTypeParam , ScParameter }
12
12
import org .jetbrains .plugins .scala .lang .psi .api .toplevel .ScTypedDefinition
13
13
import org .jetbrains .plugins .scala .lang .psi .api .toplevel .typedef .{ScTemplateDefinition , ScTypeDefinition }
14
14
import org .jetbrains .plugins .scala .lang .psi .types .nonvalue .{Parameter , ScMethodType , ScTypePolymorphicType , TypeParameter }
15
15
import org .jetbrains .plugins .scala .lang .psi .types .result .TypingContext
16
16
17
+ import scala .annotation .tailrec
17
18
import scala .collection .immutable .{HashMap , HashSet , Map }
18
19
19
20
/**
@@ -110,8 +111,8 @@ class ScSubstitutor(val tvMap: Map[(String, String), ScType],
110
111
private def followed (s : ScSubstitutor , level : Int ): ScSubstitutor = {
111
112
if (level > ScSubstitutor .followLimit)
112
113
throw new RuntimeException (" Too much followers for substitutor: " + this .toString)
113
- if (follower == null && tvMap.size + aliasesMap.size == 0 && updateThisType == None && ! myDependentMethodTypesFunDefined) s
114
- else if (s.getFollower == null && s.tvMap.size + s.aliasesMap.size == 0 && s.updateThisType == None && ! s.myDependentMethodTypesFunDefined) this
114
+ if (follower == null && tvMap.size + aliasesMap.size == 0 && updateThisType.isEmpty && ! myDependentMethodTypesFunDefined) s
115
+ else if (s.getFollower == null && s.tvMap.size + s.aliasesMap.size == 0 && s.updateThisType.isEmpty && ! s.myDependentMethodTypesFunDefined) this
115
116
else {
116
117
val res = new ScSubstitutor (tvMap, aliasesMap, updateThisType,
117
118
if (follower != null ) follower followed (s, level + 1 ) else s)
@@ -130,7 +131,7 @@ class ScSubstitutor(val tvMap: Map[(String, String), ScType],
130
131
}
131
132
132
133
private def extractTpt (tpt : ScTypeParameterType , t : ScType ): ScType = {
133
- if (tpt.args.length == 0 ) t
134
+ if (tpt.args.isEmpty ) t
134
135
else t match {
135
136
case ScParameterizedType (designator, _) => designator
136
137
case _ => t
@@ -330,7 +331,7 @@ class ScSubstitutor(val tvMap: Map[(String, String), ScType],
330
331
case tpt : ScTypeParameterType =>
331
332
tvMap.get((tpt.name, tpt.getId)) match {
332
333
case Some (param : ScParameterizedType ) if pt != param =>
333
- if (tpt.args.length == 0 ) {
334
+ if (tpt.args.isEmpty ) {
334
335
substInternal(param) // to prevent types like T[A][A]
335
336
} else {
336
337
ScParameterizedType (param.designator, typeArgs.map(substInternal))
@@ -344,7 +345,7 @@ class ScSubstitutor(val tvMap: Map[(String, String), ScType],
344
345
case u : ScUndefinedType =>
345
346
tvMap.get((u.tpt.name, u.tpt.getId)) match {
346
347
case Some (param : ScParameterizedType ) if pt != param =>
347
- if (u.tpt.args.length == 0 ) {
348
+ if (u.tpt.args.isEmpty ) {
348
349
substInternal(param) // to prevent types like T[A][A]
349
350
} else {
350
351
ScParameterizedType (param.designator, typeArgs map substInternal)
@@ -358,7 +359,7 @@ class ScSubstitutor(val tvMap: Map[(String, String), ScType],
358
359
case u : ScAbstractType =>
359
360
tvMap.get((u.tpt.name, u.tpt.getId)) match {
360
361
case Some (param : ScParameterizedType ) if pt != param =>
361
- if (u.tpt.args.length == 0 ) {
362
+ if (u.tpt.args.isEmpty ) {
362
363
substInternal(param) // to prevent types like T[A][A]
363
364
} else {
364
365
ScParameterizedType (param.designator, typeArgs map substInternal)
@@ -714,7 +715,7 @@ class ScUndefinedSubstitutor(val upperMap: Map[(String, String), HashSet[ScType]
714
715
case None =>
715
716
}
716
717
717
- if (tvMap.get(name) == None ) {
718
+ if (tvMap.get(name).isEmpty ) {
718
719
tvMap += ((name, Nothing ))
719
720
}
720
721
tvMap.get(name)
0 commit comments