<commit_before>package dyvil.tools.compiler.ast.type.generic;

import dyvil.tools.compiler.ast.classes.IClass;
import dyvil.tools.compiler.ast.context.IContext;
import dyvil.tools.compiler.ast.generic.ITypeParameter;
import dyvil.tools.compiler.ast.modifiers.ModifierUtil;
import dyvil.tools.compiler.ast.type.IType;
import dyvil.tools.compiler.util.Markers;
import dyvil.tools.parsing.marker.Marker;
import dyvil.tools.parsing.marker.MarkerList;
import dyvil.tools.parsing.position.ICodePosition;

public class ResolvedGenericType extends ClassGenericType
{
	protected ICodePosition position;

	public ResolvedGenericType(ICodePosition position)
	{
		super();
		this.position = position;
	}

	public ResolvedGenericType(ICodePosition position, IClass iclass)
	{
		super(iclass);
		this.position = position;
	}

	public ResolvedGenericType(ICodePosition position, IClass iclass, IType[] typeArguments, int typeArgumentCount)
	{
		super(iclass, typeArguments, typeArgumentCount);
		this.position = position;
	}

	@Override
	public ICodePosition getPosition()
	{
		return this.position;
	}

	@Override
	public void setPosition(ICodePosition position)
	{
		this.position = position;
	}

	@Override
	public void checkType(MarkerList markers, IContext context, TypePosition position)
	{
		final IClass theClass = this.theClass;
		if (theClass != null)
		{
			ModifierUtil.checkVisibility(theClass, this.position, markers, context);
		}

		// Check if the Type Variable Bounds accept the supplied Type Arguments
		for (int i = 0; i < this.typeArgumentCount; i++)
		{
			final ITypeParameter typeVariable = this.theClass.getTypeParameter(i);
			final IType type = this.typeArguments[i];
			if (typeVariable != null && type.isResolved() && !typeVariable.isSuperTypeOf(type))
			{
				final Marker marker = Markers
						.semantic(type.getPosition(), "generic.type.incompatible", typeVariable.getName().qualified,
						          this.theClass.getFullName());
				marker.addInfo(Markers.getSemantic("generic.type", type));
				marker.addInfo(Markers.getSemantic("typeparameter.declaration", typeVariable));
				markers.add(marker);
			}
		}

		if (position == TypePosition.CLASS)
		{
			markers.add(Markers.semanticError(this.position, "type.class.generic"));
		}

		// If the position is a SUPER_TYPE position
		if (position == TypePosition.SUPER_TYPE || position == TypePosition.SUPER_TYPE_ARGUMENT)
		{
			position = TypePosition.SUPER_TYPE_ARGUMENT;<commit_msg>Fix Generic Type Resolution<commit_after>package dyvil.tools.compiler.ast.type.generic;

import dyvil.tools.compiler.ast.classes.IClass;
import dyvil.tools.compiler.ast.context.IContext;
import dyvil.tools.compiler.ast.generic.ITypeParameter;
import dyvil.tools.compiler.ast.modifiers.ModifierUtil;
import dyvil.tools.compiler.ast.type.IType;
import dyvil.tools.compiler.util.Markers;
import dyvil.tools.parsing.marker.Marker;
import dyvil.tools.parsing.marker.MarkerList;
import dyvil.tools.parsing.position.ICodePosition;

public class ResolvedGenericType extends ClassGenericType
{
	protected ICodePosition position;

	public ResolvedGenericType(ICodePosition position)
	{
		super();
		this.position = position;
	}

	public ResolvedGenericType(ICodePosition position, IClass iclass)
	{
		super(iclass);
		this.position = position;
	}

	public ResolvedGenericType(ICodePosition position, IClass iclass, IType[] typeArguments, int typeArgumentCount)
	{
		super(iclass, typeArguments, typeArgumentCount);
		this.position = position;
	}

	@Override
	public ICodePosition getPosition()
	{
		return this.position;
	}

	@Override
	public void setPosition(ICodePosition position)
	{
		this.position = position;
	}

	@Override
	public void checkType(MarkerList markers, IContext context, TypePosition position)
	{
		ModifierUtil.checkVisibility(this.theClass, this.position, markers, context);

		// Check if the Type Variable Bounds accept the supplied Type Arguments
		final int count = Math.min(this.typeArgumentCount, this.theClass.typeParameterCount());
		for (int i = 0; i < count; i++)
		{
			final ITypeParameter typeVariable = this.theClass.getTypeParameter(i);
			final IType type = this.typeArguments[i];

			if (type.isResolved() && !typeVariable.isSuperTypeOf(type))
			{
				final Marker marker = Markers.semantic(type.getPosition(), "generic.type.incompatible",
				                                       typeVariable.getName().qualified, this.theClass.getFullName());
				marker.addInfo(Markers.getSemantic("generic.type", type));
				marker.addInfo(Markers.getSemantic("typeparameter.declaration", typeVariable));
				markers.add(marker);
			}
		}

		if (position == TypePosition.CLASS)
		{
			markers.add(Markers.semanticError(this.position, "type.class.generic"));
		}

		// If the position is a SUPER_TYPE position
		if (position == TypePosition.SUPER_TYPE || position == TypePosition.SUPER_TYPE_ARGUMENT)
		{
			position = TypePosition.SUPER_TYPE_ARGUMENT;
{'fraction_non_alphanumeric': 0.10635275015222245, 'fraction_numerical': 0.00040592652729855896, 'mean_word_length': 4.79764705882353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3875066', 'n_tokens_mistral': 1631, 'n_tokens_neox': 1491, 'n_words': 301}