Compile-Time Resolution
TLDR: Compile-time resolution refers to the process where the compiler determines the method, function, or operator to execute based on the method signature, including the type, number, and order of parameters. This static resolution ensures that the correct implementation is selected before the program runs, providing type safety and performance optimizations. It is a key feature in overloading and static binding in languages like Java, CPP, and C Sharp.
https://en.wikipedia.org/wiki/Static_binding
During compile-time resolution, the compiler analyzes the method call and matches it against the available definitions within the class or scope. For example, if a class has overloaded methods `calculate(int a, int b)` and `calculate(double a, double b)`, the compiler resolves the correct version based on the argument types in the method call. This eliminates ambiguity and ensures that the method being invoked adheres to the expected method signature, reducing the risk of runtime errors.
https://docs.oracle.com/javase/tutorial/java/javaOO/methods.html
The primary advantage of compile-time resolution is its efficiency, as decisions about method calls are made before runtime. This enables the compiler to generate optimized bytecode or machine code. However, compile-time resolution is limited to scenarios where all information about the method call is available at compile time. For dynamic or overridden methods, runtime resolution (e.g., dynamic dispatch) is required. Together, these mechanisms provide the flexibility and reliability needed for robust programming practices.
https://docs.oracle.com/javase/specs/jls/se20/html/jls-8.html