mirror of
https://github.com/adelphes/android-dev-ext.git
synced 2025-12-23 01:48:18 +00:00
add support for generic inferred-type arguments
This commit is contained in:
@@ -4,7 +4,8 @@
|
|||||||
*
|
*
|
||||||
* Each token also contains detailed state information used for completion suggestions.
|
* Each token also contains detailed state information used for completion suggestions.
|
||||||
*/
|
*/
|
||||||
const { JavaType, CEIType, PrimitiveType, ArrayType, UnresolvedType, NullType, WildcardType, TypeVariable, Field, Method, ReifiedMethod, Parameter, Constructor, signatureToType } = require('java-mti');
|
const { JavaType, CEIType, PrimitiveType, ArrayType, UnresolvedType, NullType, WildcardType, TypeVariableType,
|
||||||
|
TypeVariable, InferredTypeArgument, Field, Method, ReifiedMethod, Parameter, Constructor, signatureToType } = require('java-mti');
|
||||||
const { SourceMethod, SourceConstructor, SourceInitialiser } = require('./source-type');
|
const { SourceMethod, SourceConstructor, SourceInitialiser } = require('./source-type');
|
||||||
const ResolvedImport = require('./parsetypes/resolved-import');
|
const ResolvedImport = require('./parsetypes/resolved-import');
|
||||||
const ParseProblem = require('./parsetypes/parse-problem');
|
const ParseProblem = require('./parsetypes/parse-problem');
|
||||||
@@ -1269,6 +1270,10 @@ function isTypeArgumentCompatible(dest_typevar, value_typevar_type) {
|
|||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (value_typevar_type instanceof TypeVariableType) {
|
||||||
|
// inferred type arguments of the form `x = List<>` are compatible with every destination type variable
|
||||||
|
return value_typevar_type.typeVariable instanceof InferredTypeArgument;
|
||||||
|
}
|
||||||
return dest_typevar.type === value_typevar_type;
|
return dest_typevar.type === value_typevar_type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -89,7 +89,16 @@ function typeIdent(tokens, scope, imports, typemap, allow_array_qualifiers = tru
|
|||||||
* @param {Map<string,JavaType>} typemap
|
* @param {Map<string,JavaType>} typemap
|
||||||
*/
|
*/
|
||||||
function genericTypeArgs(tokens, types, scope, imports, typemap) {
|
function genericTypeArgs(tokens, types, scope, imports, typemap) {
|
||||||
if (!tokens.isValue('>')) {
|
if (tokens.isValue('>')) {
|
||||||
|
// <> operator - build new types with inferred type arguments
|
||||||
|
types.forEach((t,i,arr) => {
|
||||||
|
if (t instanceof CEIType) {
|
||||||
|
let specialised = t.makeInferredTypeArgs();
|
||||||
|
arr[i] = specialised;
|
||||||
|
}
|
||||||
|
});
|
||||||
|
return;
|
||||||
|
}
|
||||||
const type_arguments = typeIdentList(tokens, scope, imports, typemap);
|
const type_arguments = typeIdentList(tokens, scope, imports, typemap);
|
||||||
types.forEach((t,i,arr) => {
|
types.forEach((t,i,arr) => {
|
||||||
if (t instanceof CEIType) {
|
if (t instanceof CEIType) {
|
||||||
@@ -108,7 +117,6 @@ function genericTypeArgs(tokens, types, scope, imports, typemap) {
|
|||||||
tokens.splice(tokens.idx, 1, ...new_tokens);
|
tokens.splice(tokens.idx, 1, ...new_tokens);
|
||||||
}
|
}
|
||||||
tokens.expectValue('>');
|
tokens.expectValue('>');
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user