@@ -51,46 +51,59 @@ protected Scope getScope(Scope scope) {
51
51
52
52
if (count > 0 ) {
53
53
ScopeTable table = scope .getTable ();
54
- ScopeState state = scope .getState ();
55
- Constraint first = table .getConstraint (start );
54
+ Address address = AddressCache .getAddress (count );
55
+ Constraint parameter = table .getConstraint (address );
56
+
57
+ if (parameter != null ) {
58
+ throw new InternalStateException ("Generic parameter count for '" + attribute + "' is invalid" );
59
+ }
60
+ return getScope (scope , count );
61
+ }
62
+ return scope ;
63
+ }
64
+
65
+ private Scope getScope (Scope scope , int count ) {
66
+ List <Constraint > defaults = attribute .getGenerics ();
67
+ ScopeTable table = scope .getTable ();
68
+ ScopeState state = scope .getState ();
69
+ Constraint first = table .getConstraint (start );
56
70
57
- for (int i = 0 ; i < count ; i ++) {
58
- Address address = AddressCache .getAddress (i );
59
- Constraint parameter = table .getConstraint (address );
60
- Constraint constraint = defaults .get (i );
61
- String name = constraint .getName (scope );
62
- Constraint existing = state .getConstraint (name );
71
+ for (int i = 0 ; i < count ; i ++) {
72
+ Address address = AddressCache .getAddress (i );
73
+ Constraint parameter = table .getConstraint (address );
74
+ Constraint constraint = defaults .get (i );
75
+ String name = constraint .getName (scope );
76
+ Constraint existing = state .getConstraint (name );
63
77
64
- if (parameter != null ) {
65
- Type require = constraint .getType (scope );
66
- Type actual = parameter .getType (scope );
78
+ if (parameter != null ) {
79
+ Type require = constraint .getType (scope );
80
+ Type actual = parameter .getType (scope );
67
81
68
- if (!checker .isInstanceOf (scope , actual , require )) {
69
- throw new InternalStateException ("Generic parameter '" + name +"' does not match '" + constraint + "'" );
70
- }
71
- if (existing != null ) {
72
- Type current = existing .getType (scope );
82
+ if (!checker .isInstanceOf (scope , actual , require )) {
83
+ throw new InternalStateException ("Generic parameter '" + name +"' does not match '" + constraint + "'" );
84
+ }
85
+ if (existing != null ) {
86
+ Type current = existing .getType (scope );
73
87
74
- if (current != actual ) {
75
- throw new InternalStateException ("Generic parameter '" + name +"' has already been declared" );
76
- }
77
- } else {
78
- state .addConstraint (name , parameter );
88
+ if (current != actual ) {
89
+ throw new InternalStateException ("Generic parameter '" + name +"' has already been declared" );
79
90
}
80
91
} else {
81
- if (first != null ) {
82
- throw new InternalStateException ("Generic parameter '" + name +"' not specified" );
83
- }
84
- if (existing != null ) {
85
- Type require = mapper .map (scope , constraint );
86
- Type current = mapper .map (scope , existing );
92
+ state .addConstraint (name , parameter );
93
+ }
94
+ } else {
95
+ if (first != null ) {
96
+ throw new InternalStateException ("Generic parameter '" + name +"' not specified" );
97
+ }
98
+ if (existing != null ) {
99
+ Type require = mapper .map (scope , constraint );
100
+ Type current = mapper .map (scope , existing );
87
101
88
- if (current != require ) {
89
- throw new InternalStateException ("Generic parameter '" + name + "' has already been declared" );
90
- }
91
- } else {
92
- state .addConstraint (name , constraint );
102
+ if (current != require ) {
103
+ throw new InternalStateException ("Generic parameter '" + name + "' has already been declared" );
93
104
}
105
+ } else {
106
+ state .addConstraint (name , constraint );
94
107
}
95
108
}
96
109
}
0 commit comments